Hello,
I am currently working on displaying and hiding all other columns in a range based on a drop down. In row 7 I have all the columns identified by text, which is the same as the drop down list. When an user selects the drop down, the sheet should hide all other columns except the one selected. The following code does not seem to work:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim R, V
If Target.Address = ("$f$3") Then
V = [F3].Value
For Each R In Range("J7:FV7")
If IsError(R.Value) Then
R.EntireColumn.Hidden = True
Else
R.EntireColumn.Hidden = R.Value <> V
End If
Next
End If
End Sub
I am not sure if it is because I have other VBA codes on the sheet or if the above is bad coding. I seem to always have issue with Private Sub Worksheet_Change(ByVal Target As Range) code.... Not sure if that is the issue....
Help Gurus!
Thanks!
Novice
I am currently working on displaying and hiding all other columns in a range based on a drop down. In row 7 I have all the columns identified by text, which is the same as the drop down list. When an user selects the drop down, the sheet should hide all other columns except the one selected. The following code does not seem to work:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim R, V
If Target.Address = ("$f$3") Then
V = [F3].Value
For Each R In Range("J7:FV7")
If IsError(R.Value) Then
R.EntireColumn.Hidden = True
Else
R.EntireColumn.Hidden = R.Value <> V
End If
Next
End If
End Sub
I am not sure if it is because I have other VBA codes on the sheet or if the above is bad coding. I seem to always have issue with Private Sub Worksheet_Change(ByVal Target As Range) code.... Not sure if that is the issue....
Help Gurus!
Thanks!
Novice