Hello!
I found and adapted a code that hides columns in which a certain range contains a "0". The problem is, when I run the code, I keep seeing the worksheets activate, even with ScreenUpdating set to False. (running MacOS)
Code:
I had to add the "Worksheets.Activate" because the code wouldn't run if I didn't have the sheet selected.
Any help is appreciated!
I found and adapted a code that hides columns in which a certain range contains a "0". The problem is, when I run the code, I keep seeing the worksheets activate, even with ScreenUpdating set to False. (running MacOS)
Code:
VBA Code:
Sub Hide_Columns_With_Zero()
Dim cl, rTest As Range
Application.ScreenUpdating = False
Worksheets("Errors test").Activate
Set rTest = Sheets("Errors test").Range("B7:N7", Range("B7:N7").End(xlToRight))
For Each cl In rTest
If cl.Value = 0 Then
cl.EntireColumn.Hidden = True
Else
cl.EntireColumn.Hidden = False
End If
Next cl
Worksheets("Monthly Data").Activate
Set rTest = Sheets("Monthly Data").Range("A7:Q7", Range("A7:Q7").End(xlToRight))
For Each cl In rTest
If cl.Value = 0 Then
cl.EntireColumn.Hidden = True
Else
cl.EntireColumn.Hidden = False
End If
Next cl
Application.ScreenUpdating = True
End Sub
I had to add the "Worksheets.Activate" because the code wouldn't run if I didn't have the sheet selected.
Any help is appreciated!