Hello XL peeps,
I'm a novice with VBA/Macros, but I'm getting better at it with every new challenge I tackle. I currently have a spreadsheet with 2 main tabs. The first tab is for pasting rows of data that in turn is used on the second tab to provide provissioning data provided in steps. I pull all the cells posted on Tab 1 to Tab 2 via formulas, then use data validation to provide a drop down list of sites in cell B4. Based on the value in B4 row 4 populates with the rest of the data via VLOOKUP and I use the following sheet 2 code to call a macro that resets various fields when a new site is selected.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$4" Then
Call oewSIADnodebREHOMEfieldClear
End If
End Sub
I have an requirement now to hide or show 2 ranges of rows based on the value in cell C419, but I can't seem to get Excel to perform the function when I change the value in C419. The default value, which is also reset by the oewSIADnodebREHOMEfiledClear macro, for cell C419 is "Standard Naming". I want to toggle the hidding of rows 455:460 when "Non-Standard Naming" is selected in C419, and hide the rows when "Standard Naming" is selected.
I tried both of the approaches below in a Module, but neither of them has done a thing.
On this one, I tried adding a sub to the sheet code to try and call this macro when cell C419 was changed, but not sure if it is even possible to string Subs together in the sheet code.
Sub SIADnaming()
'
' SIADnaming Macro
'
'
If Range("C419").Value = "Standard Naming" Then Rows("455:460").Hidden = True
If Range("C419").Value = "Non-Standard Naming" Then Rows("455:460").Hidden = False
End Sub
On this one, I was hoping that just adding this to a macro would work and trigger when the cell in C419 was changed, but it has not worked at all.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(0, 0) = "C419" Then
If InStr(LCase(Target), "Non-Standard Naming") Then
Range(Rows(456), Rows(460)).EntireRow.Hidden = True
Else
Range(Rows(456), Rows(460)).EntireRow.Hidden = False
End If
End If
End Sub
Thanks in advance for your help.
Patrick
Bookmarks