+ Reply to Thread
Results 1 to 12 of 12

Hide and Unhide rows on multiple sheets based on a validation list on a single sheet

Hybrid View

bbarth Hide and Unhide rows on... 04-30-2015, 11:47 AM
Arkadi Re: Hide and Unhide rows on... 04-30-2015, 12:28 PM
bbarth Re: Hide and Unhide rows on... 04-30-2015, 12:35 PM
bbarth Re: Hide and Unhide rows on... 04-30-2015, 12:45 PM
walruseggman Re: Hide and Unhide rows on... 04-30-2015, 12:29 PM
Arkadi Re: Hide and Unhide rows on... 04-30-2015, 12:30 PM
Arkadi Re: Hide and Unhide rows on... 04-30-2015, 12:43 PM
bbarth Re: Hide and Unhide rows on... 04-30-2015, 12:51 PM
Arkadi Re: Hide and Unhide rows on... 04-30-2015, 12:46 PM
Arkadi Re: Hide and Unhide rows on... 04-30-2015, 01:00 PM
bbarth Re: Hide and Unhide rows on... 04-30-2015, 01:40 PM
Arkadi Re: Hide and Unhide rows on... 04-30-2015, 02:10 PM
  1. #1
    Registered User
    Join Date
    02-14-2014
    Location
    Farmington, Utah
    MS-Off Ver
    Excel 2013
    Posts
    43

    Hide and Unhide rows on multiple sheets based on a validation list on a single sheet

    I have around 20 sheets with data that I need to be able to hide and unhide rows based upon what data is shown in a validation list on the first sheet. I have attached an example file to hopefully clarify things. Basically I am trying to filter for location and I only want to be able to see the rows on every sheet that correspond with the information found in my validation list. Each sheet has varying amonts of columns and rows as well. Thank you for your help I really appreciate it!
    Attached Files Attached Files

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Hide and Unhide rows on multiple sheets based on a validation list on a single sheet

    If you doubleclick "ThisWorkbook" in vba editor and paste this code, it will work for all sheets when you change the value of B1:

    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    
    Dim lr As Long
    Dim i As Long
    
    If Not Intersect(Target, Sh.Range("B1")) Is Nothing Then
        Sh.Cells.EntireRow.Hidden = False
        lr = Sh.Range("A" & Rows.Count).End(xlUp).Row
        For i = 2 To lr
            If Sh.Range("A" & i).Value <> Sh.Range("B1").Value Then Sh.Range("A" & i).EntireRow.Hidden = True
            If Sh.Range("A" & i).Value = Sh.Range("B1").Value Then Sh.Range("A" & i).EntireRow.Hidden = False
        Next i
    End If
    
    End Sub
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Registered User
    Join Date
    02-14-2014
    Location
    Farmington, Utah
    MS-Off Ver
    Excel 2013
    Posts
    43

    Re: Hide and Unhide rows on multiple sheets based on a validation list on a single sheet

    Thank you for your help! This works great the first time, but when I go to change the location it only filters on the first sheet and the other sheets keep the previous filter.

  4. #4
    Registered User
    Join Date
    02-14-2014
    Location
    Farmington, Utah
    MS-Off Ver
    Excel 2013
    Posts
    43

    Re: Hide and Unhide rows on multiple sheets based on a validation list on a single sheet

    That is correct.

  5. #5
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Hide and Unhide rows on multiple sheets based on a validation list on a single sheet

    But what does the validation sheet look like? Need to know the formatting. Like is sheet name in A, filter phrase in B?

  6. #6
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Hide and Unhide rows on multiple sheets based on a validation list on a single sheet

    walrus, the validation sheet is what provides data on the pulldown in b1 of sheet1_after
    it is in the book, just hidden.

  7. #7
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Hide and Unhide rows on multiple sheets based on a validation list on a single sheet

    Well I had made it so that you need a pulldown on each sheet to filter that sheet. Are you saying you want to filter ALL sheets (excep the hidden one I guess), based just on the value of the pulldown on Sheet1?

  8. #8
    Registered User
    Join Date
    02-14-2014
    Location
    Farmington, Utah
    MS-Off Ver
    Excel 2013
    Posts
    43

    Re: Hide and Unhide rows on multiple sheets based on a validation list on a single sheet

    Currently that is how it is laid out so I could have the validation drop down on the first sheet. However, if it is easier for you to do the coding then I can easily add a row on every sheet so the headings are all on row two.

  9. #9
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Hide and Unhide rows on multiple sheets based on a validation list on a single sheet

    One more question... sheet1 has the heading in row2, and the rest of them in row1 is that your real layout or just an example?

  10. #10
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Hide and Unhide rows on multiple sheets based on a validation list on a single sheet

    Ok, how about this, but please note you need to change 2 lines of code to have the "Sheet1_After" part changed to the name of your actual sheet with pulldown. It still goes in the code for "ThisWorkbook":

    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    
    Dim lr As Long
    Dim i As Long
    
    If Not Intersect(Target, Sh.Range("B1")) Is Nothing And Sh.Name = "Sheet1_After" Then 'change "Sheet1_After" to whatever the name of the sheet with the pulldown is
        For Each ws In ThisWorkbook.Sheets
            If ws.Name <> "Validation_List" Then 'exclude validation list sheet
                ws.Cells.EntireRow.Hidden = False
                lr = ws.Range("A" & Rows.Count).End(xlUp).Row
                If ws.Name = "Sheet1_After" Then 'change to name of theet with pulldown, it will do row 3 and on for this sheet since layout is different
                    For i = 3 To lr
                        If ws.Range("A" & i).Value <> Sh.Range("B1").Value Then ws.Range("A" & i).EntireRow.Hidden = True
                        If ws.Range("A" & i).Value = Sh.Range("B1").Value Then ws.Range("A" & i).EntireRow.Hidden = False
                    Next i
                Else
                    For i = 2 To lr
                        If ws.Range("A" & i).Value <> Sh.Range("B1").Value Then ws.Range("A" & i).EntireRow.Hidden = True
                        If ws.Range("A" & i).Value = Sh.Range("B1").Value Then ws.Range("A" & i).EntireRow.Hidden = False
                    Next i
                End If
            End If
        Next ws
    End If
    
    End Sub

  11. #11
    Registered User
    Join Date
    02-14-2014
    Location
    Farmington, Utah
    MS-Off Ver
    Excel 2013
    Posts
    43

    Re: Hide and Unhide rows on multiple sheets based on a validation list on a single sheet

    Works like a charm. You are amazing, thank you I really appreciate the help!

  12. #12
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Hide and Unhide rows on multiple sheets based on a validation list on a single sheet

    Great, glad it worked out for you bbarth

+ 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 rows on multiple worksheets based on value of a drop down list
    By clo2peter in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-10-2014, 08:32 AM
  2. macro that will hide/unhide rows based on data validation selection
    By megkim2002 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-18-2012, 10:40 AM
  3. Unhide or hide sheets based on drop down list value - need help combining these two macros
    By kstrick99999 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-02-2012, 06:07 PM
  4. 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
  5. Hide/Unhide Non-contiguous rows based on Data Validation Selection
    By ahkarchem in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-08-2012, 11:52 AM

Tags for this Thread

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