Juriemagic
06-05-2015, 03:23 AM
Hi good people!
The following code hides columns when a cell in row 2 goes zero. Works great. I am after an addition to the code, to have the column, of which the cell in row 2 has gone to zero, populate with the "na()" value. Now, there are 2 ranges, the one is B3:AT137, and the other CR3:CJ43. I cannot find something on the forums that would help me out, so please, if anyone could help me, it'll be awesome!!. Thanx guys..
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Cell As Range
Set Target = Intersect(Target, Target.Parent.Rows(2))
If Not Target Is Nothing Then
For Each Cell In Target
Cell.EntireColumn.Hidden = (Cell.Value = 0)
Next Cell
End If
End Sub
The following code hides columns when a cell in row 2 goes zero. Works great. I am after an addition to the code, to have the column, of which the cell in row 2 has gone to zero, populate with the "na()" value. Now, there are 2 ranges, the one is B3:AT137, and the other CR3:CJ43. I cannot find something on the forums that would help me out, so please, if anyone could help me, it'll be awesome!!. Thanx guys..
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Cell As Range
Set Target = Intersect(Target, Target.Parent.Rows(2))
If Not Target Is Nothing Then
For Each Cell In Target
Cell.EntireColumn.Hidden = (Cell.Value = 0)
Next Cell
End If
End Sub