Dears
I want create auto working monthly comparative charts as u know, to create a proper chart i have to hide unrealized months, for example i am working on Jan2June chart for now after June values are 0 but chart still shows after June months but it is not necessary. I want to auto hide columns with VBA i have very simple code but it has some crash when i add more criteria. If i only define 6. month (June) the code works fine hides after June months. But ,if i add 7. month in code it works for July when i write 7 in to trigger cell but when i write 6 to trigger cell it only hide July and keeps other columns (months) unhide. Where is the bug ? Thanks in advance.
If Range("P1").Value = 6 Then
Columns("I:N").EntireColumn.Hidden = True
Columns("X:AC").EntireColumn.Hidden = True
Else
Columns("I:N").EntireColumn.Hidden = False
Columns("X:AC").EntireColumn.Hidden = False
End If
If Range("P1").Value = 7 Then
Columns("J:N").EntireColumn.Hidden = True
Columns("Y:AC").EntireColumn.Hidden = True
Else
Columns("J:N").EntireColumn.Hidden = False
Columns("Y:AC").EntireColumn.Hidden = False
End If
End Sub
I want create auto working monthly comparative charts as u know, to create a proper chart i have to hide unrealized months, for example i am working on Jan2June chart for now after June values are 0 but chart still shows after June months but it is not necessary. I want to auto hide columns with VBA i have very simple code but it has some crash when i add more criteria. If i only define 6. month (June) the code works fine hides after June months. But ,if i add 7. month in code it works for July when i write 7 in to trigger cell but when i write 6 to trigger cell it only hide July and keeps other columns (months) unhide. Where is the bug ? Thanks in advance.
If Range("P1").Value = 6 Then
Columns("I:N").EntireColumn.Hidden = True
Columns("X:AC").EntireColumn.Hidden = True
Else
Columns("I:N").EntireColumn.Hidden = False
Columns("X:AC").EntireColumn.Hidden = False
End If
If Range("P1").Value = 7 Then
Columns("J:N").EntireColumn.Hidden = True
Columns("Y:AC").EntireColumn.Hidden = True
Else
Columns("J:N").EntireColumn.Hidden = False
Columns("Y:AC").EntireColumn.Hidden = False
End If
End Sub