Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default CF (If Formula Is ) placed into macro

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,393
Default CF (If Formula Is ) placed into macro

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
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Driftwood" wrote in message
...
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
use macro to copy formula with value and not formula without value ramzi Excel Programming 3 August 4th 08 02:07 PM
Formula in a macro mathel Excel Programming 3 November 3rd 07 07:31 AM
Formula in macro causes macro to fail KCK Excel Programming 2 February 8th 07 08:47 PM
Macro Formula for Max value Gary''s Student Excel Worksheet Functions 0 November 30th 06 05:20 PM
Formula expected end of statement error, typing formula into cell as part of VBA macro [email protected] Excel Programming 1 July 20th 06 07:58 PM


All times are GMT +1. The time now is 02:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"