Hiding a variable amount of rows based on a drop down in a different worksheet

  • Hello,


    I am trying to hide a variable number of rows in 8 different worksheets based on a name selected from a drop down menu in a different worksheet. Each time a new name is selected in the drop down all the rows need to be unhidden then re-hidden based on the new name.


    In sheet 1 I have a drop down with roughly 200 names. Each time one is selected I need all the rows NOT associated with this name to become hidden in Sheets 4-12 and only show the rows that include the selected name. If possible I would then like to password protect sheets 4-12 so they cannot be edited or manipulated in any way.


    Here is a synopsis of my workbook:
    Sheet 1 is the dashboard and contains results that have been compiled in a different worksheet (Sheet 3)
    Sheet 2 is very hidden and contains the list of names that appear in the drop down and a number associated to them (some names have multiple numbers and some only have 1)
    Sheet 3 is very hidden and contains the compiled data from sheets 4-11 based on name
    Sheets 4-12 have the data that is being compiled into sheet 3 and shown on sheet 1. these sheets currently have just the number associated with each name but I can add a column for the name if needed to make this work.
    Sheets 4-12 can have from 10-1500 rows of data depending on the month


    When presenting the data to the specific name selected in the drop down in sheet 1 I need only the data (rows) within sheets 4-12 that corresponds to this name shown and all the other rows hidden from view.


    So far this is the code I have to unhide all the rows. I am unsure of how to call each case in order for the code to hide the necessary rows.



    Any help would be greatly appreciated.

  • Re: Hiding a variable amount of rows based on a drop down in a different worksheet


    Your description does not match the code...


    Quote

    specific name selected in the drop down in sheet 1


    But the code runs on a changes on sheets 4 - 12

    Code
    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) 
        Select Case Sh.Index 
        Case 4, 5, 6, 7, 8, 9, 10, 11, 12


    Please upload a sample workbook


    [sw]*[/sw]

  • Re: Hiding a variable amount of rows based on a drop down in a different worksheet


    cytop, I have added a smaple workbook of my data. The VBA code is within the VQR worksheet.


    I didn't realize CASE was calling from those worksheets. The C4 reference drop-down is in the VQR sheet. In that case the area where CASE is should just reference Sheet 1.

  • Re: Hiding a variable amount of rows based on a drop down in a different worksheet


    This, in the worksheet class module for the sheet VQR, will hide rows as you requested.


    However, because of the amount of processing, there's a very noticable delay after selecting something from the dropdown.


    Because of this, I haven't tackled the password - I think you need to have another look at how this works, even if only to add a button to actually filter the sheets and apply the password when the user is ready to 'lock it down'.

  • Re: Hiding a variable amount of rows based on a drop down in a different worksheet


    Thank you very much cytop. That worked great for what I needed.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!