CF (If Formula Is ) placed into macro

D

Driftwood

In row 5 (C5 - AF5) are dates from 1 - 31
Then from C8 - AG25 I will need the cells under the column
for the weekends to be gray by macro.
I have always used conditional formatting for this, but now
I will have to use my three CF's for something other than specifying the
weekends
How do I put these CF's into a macro to format
the cells light gray from C8 - AG25 ?
If Formula is =WEEKDAY(E$5,2)>=6
If Formula is =WEEKDAY(F$5,2)>=7
etc
 
B

Bernard Liengme

I recorded a macro to make the active cell grey if E5 was a weekend. Here is
the result

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 12/01/2009 by Bernard V Liengme
'

'
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=WEEKDAY(E$5,2)>=6"
Selection.FormatConditions(1).Interior.ColorIndex = 15
End Sub

Using that as a guid I coded this
Sub Macro2()
With Range("G10")
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=WEEKDAY(E$5,2)>=6"
.FormatConditions(1).Interior.ColorIndex = 15
End With
End Sub

best wishes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top