rmatenchuk
New Member
- Joined
- Jun 11, 2010
- Messages
- 16
Hi,
I am struggling to create a macro for hidding columns based on various tabs with a true or false trigger.
Below is my code... what am I doing wrong?
Probably a quick one for you guys, but tearing my hair out! Also - it is likely I can slim it down, any pointers are very welcomed.
Sub hide_master()
Application.ScreenUpdating = False
Dim rng As Range
Dim mycell As Range
Set rng = Range("A5:eY5")
Dim rng2 As Range
Dim mycell2 As Range
Set rng2 = Range("A1:eY1")
Sheets("Summary").Activate
For Each mycell In rng
If mycell.Value = "False" Then
mycell.EntireColumn.Hidden = True
End If
Next
For Each mycell In rng
If mycell.Value = "true" Then
mycell.EntireColumn.Hidden = False
End If
Next
Sheets("OWNER OCC").Activate
For Each mycell2 In rng2
If mycell2.Value = "False" Then
mycell2.EntireColumn.Hidden = True
End If
Next
For Each mycell2 In rng2
If mycell2.Value = "true" Then
mycell2.EntireColumn.Hidden = False
End If
Next
Application.ScreenUpdating = True
Sheets("Summary").Activate
End Sub
I am struggling to create a macro for hidding columns based on various tabs with a true or false trigger.
Below is my code... what am I doing wrong?
Probably a quick one for you guys, but tearing my hair out! Also - it is likely I can slim it down, any pointers are very welcomed.
Sub hide_master()
Application.ScreenUpdating = False
Dim rng As Range
Dim mycell As Range
Set rng = Range("A5:eY5")
Dim rng2 As Range
Dim mycell2 As Range
Set rng2 = Range("A1:eY1")
Sheets("Summary").Activate
For Each mycell In rng
If mycell.Value = "False" Then
mycell.EntireColumn.Hidden = True
End If
Next
For Each mycell In rng
If mycell.Value = "true" Then
mycell.EntireColumn.Hidden = False
End If
Next
Sheets("OWNER OCC").Activate
For Each mycell2 In rng2
If mycell2.Value = "False" Then
mycell2.EntireColumn.Hidden = True
End If
Next
For Each mycell2 In rng2
If mycell2.Value = "true" Then
mycell2.EntireColumn.Hidden = False
End If
Next
Application.ScreenUpdating = True
Sheets("Summary").Activate
End Sub