Hi All,
Can you please take a gander and see what am I doing wrong here? Its just a code to hide columns based on a row that has "X" in place.
It works on the active sheet but doesn't go to the next ws. THanks in advance.
Can you please take a gander and see what am I doing wrong here? Its just a code to hide columns based on a row that has "X" in place.
It works on the active sheet but doesn't go to the next ws. THanks in advance.
VBA Code:
Sub TEST_TEST()
Dim ws As Variant, Xrow As Long, LCol As Long
Application.ScreenUpdating = True
For Each ws In Worksheets(Array("Income Statement", "OCC"))
Xrow = 5
LCol = ws.Cells(4, Columns.Count).End(xlToLeft).Column
With ws
For x = 1 To LCol
If Cells(Xrow, x) <> "X" Then
Columns(x).Hidden = True
Else
Columns(x).Hidden = False
End If
Next x
End With
Next ws
Application.ScreenUpdating = False