Hello guys,
I have some trouble with the if function on VBA.
I Want to hide rows and columns if one cell is =0.
The code to hide the rows and columns works separately.
But when both are actives its like they are on the same loop. If k7 is not =0 but c19 is, the columns will not be hidden and vice versa.
Apparently both condition must be validated to run. But it's not supposed to... I want each if loop to run independently.
Thanks
Code
- Private Sub Worksheet_Change(ByVal Target As Range)
- If Range("k7").Value = 0 Then
- Columns("k").EntireColumn.Hidden = True
- Else
- Columns("k").EntireColumn.Hidden = False
- End If
- If Range("c19").Value = 0 Then
- Rows("19:83").EntireRow.Hidden = True
- Else
- Rows("19:83").EntireColumn.Hidden = False
- End If
- End sub