I created a simple spreadsheet with a bit of VBA code to hide/unhide based upon the color of the column header. If the column header is red, and I want it hidden, then I click the button "Hide". Alternatively, if I want those hidden columns to reappear, I click "Unhide". It works. Yay!
The actual task of unhiding/hiding works, the problem is that it takes entirely too long.
Here's the code for hiding:
Sub HideColumnIfRed()
Dim c As Range
For Each c In Range("A:AT")
If c.Interior.Color = vbRed Then
c.EntireColumn.Hidden = True
End If
Next c
End Sub
Here's the code for unhiding:
Sub HideColumnIfRed()
Dim c As Range
For Each c In Range("A:AT")
If c.Interior.Color = vbRed Then
c.EntireColumn.Hidden = False
End If
Next c
End Sub
What can I do to optimize this task?
Thank you in advance.