U
u473
Using Excel 2007
Row 1 has a header of calendar dates.
I apply a conditional formatting formula to shade weekend headers in
yellow.
Then I execute the following code to hide columns with shaded headers,
but nothing happens.
..
Sub HideShadedCols()
Dim myRange As Range
For i = 9 To 256
Set myRange = Cells(1, i)
If myRange.Interior.ColorIndex <> xlNone Then
myRange.EntireColumn.Hidden = True
End If
Next
End Sub
..
However, for test purpose, if I color some headers cells the hard way
and run my code,
it hides the shaded columns properly.
The question is, since the applied conditional formating is not
recognized by VBA
what intermediate statements do I have to insert ?
Thank you for your help.
J.P.
Row 1 has a header of calendar dates.
I apply a conditional formatting formula to shade weekend headers in
yellow.
Then I execute the following code to hide columns with shaded headers,
but nothing happens.
..
Sub HideShadedCols()
Dim myRange As Range
For i = 9 To 256
Set myRange = Cells(1, i)
If myRange.Interior.ColorIndex <> xlNone Then
myRange.EntireColumn.Hidden = True
End If
Next
End Sub
..
However, for test purpose, if I color some headers cells the hard way
and run my code,
it hides the shaded columns properly.
The question is, since the applied conditional formating is not
recognized by VBA
what intermediate statements do I have to insert ?
Thank you for your help.
J.P.