PC Review


Reply
Thread Tools Rate Thread

CF (If Formula Is ) placed into macro

 
 
Driftwood
Guest
Posts: n/a
 
      12th Jan 2009
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 With Quote
 
 
 
 
Bernard Liengme
Guest
Posts: n/a
 
      12th Jan 2009
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" <(E-Mail Removed)> wrote in message
news:AC3950C3-3DBE-41F8-B939-(E-Mail Removed)...
> 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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
store formula in macro then paste it when macro runs Nina Microsoft Excel Programming 2 16th Dec 2009 07:21 PM
formula or macro to change a formula in muliple spreadsheets mel.pilgrim@agr.gc.ca Microsoft Excel Programming 1 21st May 2009 05:27 PM
use macro to copy formula with value and not formula without value ramzi Microsoft Excel Programming 3 4th Aug 2008 02:07 PM
Formula in macro causes macro to fail =?Utf-8?B?S0NL?= Microsoft Excel Programming 2 8th Feb 2007 08:47 PM
Formula expected end of statement error, typing formula into cell as part of VBA macro DavidGMullins@gmail.com Microsoft Excel Programming 1 20th Jul 2006 07:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:26 PM.