Need to hide/ unhide rows in a multiple excel sheets based on dropdown cell values in a cell of another sheet. I have 3 sheets, Dashbaord, Data Inputs, Metrics table, I have put the following code in Dashboard sheet. The 3 cells mentioned below are dropdown and contain different set of values.
When a user selects one value say in dropdown C4, I'm hiding/ unhiding certain rows in all the 3 sheets mentioned above. But only the select case of cell C4 works fine. As you can see I have formulas for C23 and C32 as well, but it doesn't seem to work, not sure it is due to operations on same sheets
Another example, when say I select a dropdown value for Cell C23. The operations listed under C23 below works fine (respective macro is called and rows are hidden/ unhidden). But when I check the earlier selection on Cell value C4 is gone.
Please help
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
If Not Intersect(Target, Range("C4,C23,C32")) Is Nothing Then
For Each c In Intersect(Target, Range("C4,C23,C32"))
Select Case c.Address(0, 0)
Case "C4"
If Target.Value = "Ecommerce" Then Call Ecommerce
If Target.Value = "Non-Commerce" Then Call NonCommerce
If Target.Value = "Ecommerce & Non-Commerce" Then Call Both
If Target.Value = "Select Ecommerce/Non-Commerce" Then Call Both
Case "C23"
If Target.Value = "Select Year" Then Call SelectYear
If Target.Value = "2020" Then Call Twentytwenty
If Target.Value = "2021" Then Call TwentyOne
If Target.Value = "2022" Then Call TwentyTwo
If Target.Value = "2023" Then Call TwentyThree
If Target.Value = "2024" Then Call TwentyFour
If Target.Value = "2025" Then Call TwentyFive
Case "C32"
If Target.Value = "Select PPC" Then Call SelectPPC
If Target.Value = "PPC 2" Then Call PPCTwo
If Target.Value = "PPC 3" Then Call PPCThree
If Target.Value = "PPC 4" Then Call PPCFour
If Target.Value = "PPC 5" Then Call PPCFive
If Target.Value = "PPC 6" Then Call PPCSix
If Target.Value = "PPC 7" Then Call PPCSeven
End Select
Next c
End If
End Sub
I want the sheet to operate on all the 3 cells together, right now its broken and only one works at a time. Appreciate your help.
If
statements altogether and just callCase "C23" // Call myYearMacro(Target.Value)
? – BruceWaynec.Value
notTarget.Value
– Scott CranerSelect Case
for the three options, what if you just didIf c.Address(0,0) = "C4" Then // [those options] // End If // If c.Address(0,0) = "C23" Then // [those options] // End If // If c.Address(0,0) = "C32" Then // [those options // End If
. That way, it'll checkc.Address()
three times, instead of just the once...? – BruceWayne