Thursday, 22 August 2019

microsoft excel - Hide and unhide rows dependent upon pull down list

I have a Cell (D3) with a pull down menu of 8 items (all words). Dependent upon the pull down item selected, I want to hide, all other rows without that specific word in column K (11 columns over from the start).


I also need an option to show all rows if "All Rows" if that is selected from the pull down menu.


Any ideas on the VBA to relate to the pull down menu cell value ?


Also, How do I relate the VBA code to the pull down menu when selected ?


Thank you and I appreciate any help.


Does this code look correct ? Sub PhaseTargettoStart()


Dim rMyCell As Range Set rMyCell = Range("D3") BeginRow = 6 EndRow = 301 ChkCol = 10 If Range("Audit!D3") = "Source Selection" Then Rows("6:301").EntireRow.Hidden = False


Else
If Range("Audit!D3") = "Source Selection + 4 weeks" Then
Rows("6:301").EntireRow.Hidden = False

Else
If Range("Audit!D3") = "Step 5 + 8 weeks" Then
Rows("6:301").EntireRow.Hidden = False

Else
If Range("Audit!D3") = "TKO" Then
Rows("6:301").EntireRow.Hidden = False

Else
If Range("Audit!D3") = "OTOP" Then
Rows("6:301").EntireRow.Hidden = False

Else
If Range("Audit!D3") = "VP" Then
Rows("6:301").EntireRow.Hidden = False

Else
If Range("Audit!D3") = "Process Audit" Then
Rows("6:301").EntireRow.Hidden = False

Else
If Range("Audit!D3") = "PDR" Then
Rows("6:301").EntireRow.Hidden = False

Else
If Range("Audit!D3") = "PS" Then
Rows("6:301").EntireRow.Hidden = False

Else
If Range("Audit!D3") = "Show All" Then
Rows("6:301").EntireRow.Hidden = True

End If

End Sub

No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...