+ Reply to Thread
Results 1 to 4 of 4

Hide or unhide rows based on value across multiple sheets

  1. #1
    Registered User
    Join Date
    10-26-2016
    Location
    Boston, USA
    MS-Off Ver
    MS Office 2013
    Posts
    4

    Hide or unhide rows based on value across multiple sheets

    Hi. I am trying to hide/unhide rows across multiple sheets based on the value of 1 or 0 in column A. There are 3 out of 5 sheets that I would like the macro to update automatically. The 1 and 0 are based off of a IF statement tied to Yes/No Drop-down. Yes = 1, No = 0.

    If yes is selected, I want the rows to unhide. If no is selected I wanted the rows to hide. It should update the 3 sheets at the same time, so you have to click on each.

    Here is the code I have but I get an error when I protect the sheets.


    Sub handunhrows()
    Dim arrayshts()
    Dim lr As Long
    Dim i As Long
    arrayshts = Array("Milestones", "Summary", "Worksheet")
    For Each wsheet In ThisWorkbook.Worksheets
    F = Filter(arrayshts, wsheet.Name)
    If UBound(F) >= 0 Then
    wsheet.Activate
    For i = 1 To 10000
    If wsheet.Range("A" & i).Value = "0" Then
    wsheet.Rows(i & ":" & i).EntireRow.Hidden = True 'this row has an is highlighted by debug when sheet is protected
    ElseIf wsheet.Range("A" & i).Value = "1" Then
    wsheet.Rows(i & ":" & i).EntireRow.Hidden = False
    End If
    Next i
    End If
    Next wsheet
    End Sub

  2. #2
    Valued Forum Contributor spitfireblue's Avatar
    Join Date
    01-29-2015
    Location
    Adelaide, Australia
    MS-Off Ver
    2007,2010,2016
    Posts
    611

    Re: Hide or unhide rows based on value across multiple sheets

    Hi Casper,

    In future please use code tags around any code that you post.

    You will need to unprotect each sheet when you activate it and then protect it again before you activate the next one.

    Please Login or Register  to view this content.
    Regards,
    Stephen

    If you feel someone has helped you please thank them and click on the star on their post to add reputation.
    Please ensure that you use code tags where relevant, and mark solved threads as solved.
    Most of all please be respectful and understanding of others.

  3. #3
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Hide or unhide rows based on value across multiple sheets

    You have to unprotect the sheet in code, just before the For i
    after next i you protect the sheet


    Kind regards
    Leo

  4. #4
    Registered User
    Join Date
    10-26-2016
    Location
    Boston, USA
    MS-Off Ver
    MS Office 2013
    Posts
    4

    Re: Hide or unhide rows based on value across multiple sheets

    Thank you! It worked!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Hide & Unhide Multiple Sheets based on different cell values
    By kspeese in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-19-2016, 02:46 AM
  2. HIDE/UNHIDE Rows based on cell value in multiple sheets.
    By yatin1964 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-06-2015, 12:29 AM
  3. [SOLVED] VBA to hide/unhide rows & columns on multiple sheets
    By Adam23 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-14-2015, 07:06 PM
  4. [SOLVED] Hide and Unhide rows on multiple sheets based on a validation list on a single sheet
    By bbarth in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-30-2015, 02:10 PM
  5. Macro to Hide/Unhide Multiple Rows Based on Cell Value
    By mbp727 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-17-2013, 11:12 AM
  6. Hide/Unhide rows on multiple sheets when dropdown selected from sheet 1
    By tammhelp in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-02-2012, 10:33 PM
  7. hide/unhide rows based on multiple cell values
    By saninmelbourne in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-20-2012, 06:45 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1