Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Conditional Format

I have the following VBA to enter, copy and paste conditional formats. But
it gets stuck at the first ".Add (xlExpression,...)" line.

This is what I want it to do:
If I2 is less than or equal to 60 from today and greater than 30 days from
today and A2 is not blank then highlight A2:J2 color 34...
Or
If I2 is less than or equal to 30 from today and greater than today and A2
is not blank then highlight A2:J2 color 36...
Or
If I2 is less today and A2 is not blank then highlight A2:J2 color 38 and
change font to white...
then copy formula down to last row.

Here is the current code:
With Range("a2:j2").FormatConditions
.Delete
.Add(xlExpression, ,
"=and($i2<=(today()+60),$i2(today()+30),$a2<"")" ).Interior.ColorIndex = 34
.Add(xlExpression, ,
"=and($i2<=(today()+30),$i2(today()),$a2<"")").I nterior.ColorIndex = 36
.Add(xlExpression, ,
"=and($i4<today(),$a2<"")").Interior.ColorInd ex = 38
End With
With Range("a2:j2")
.Copy
Range("a2:j" & Range("j65536").End(xlUp).Row).PasteSpecial
xlPasteFormats
End With


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Conditional Format

My apologizes for posting this twice...my browser closed down, I wasn't sure
that the post went through...

"Josh O." wrote:

I have the following VBA to enter, copy and paste conditional formats. But
it gets stuck at the first ".Add (xlExpression,...)" line.

This is what I want it to do:
If I2 is less than or equal to 60 from today and greater than 30 days from
today and A2 is not blank then highlight A2:J2 color 34...
Or
If I2 is less than or equal to 30 from today and greater than today and A2
is not blank then highlight A2:J2 color 36...
Or
If I2 is less today and A2 is not blank then highlight A2:J2 color 38 and
change font to white...
then copy formula down to last row.

Here is the current code:
With Range("a2:j2").FormatConditions
.Delete
.Add(xlExpression, ,
"=and($i2<=(today()+60),$i2(today()+30),$a2<"")" ).Interior.ColorIndex = 34
.Add(xlExpression, ,
"=and($i2<=(today()+30),$i2(today()),$a2<"")").I nterior.ColorIndex = 36
.Add(xlExpression, ,
"=and($i4<today(),$a2<"")").Interior.ColorInd ex = 38
End With
With Range("a2:j2")
.Copy
Range("a2:j" & Range("j65536").End(xlUp).Row).PasteSpecial
xlPasteFormats
End With


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Conditional Format

Ok...I figured out the other thing. But now it is entering the row number in
the conditional format incorrectly (off by one row).

For example, in row 2 it enters:
=AND($I3<=(TODAY()+60),$I3(TODAY()+30),$I30)
Instead of:
=AND($I2<=(TODAY()+60),$I2(TODAY()+30),$I20)

Here is the code as of now:
With Range("a2:j2").FormatConditions
.Delete
.Add(xlExpression, ,
"=AND($I2<=(TODAY()+60),$I2(TODAY()+30),$I20)"). Interior.ColorIndex = 34
.Add(xlExpression, ,
"=AND($I2<=(TODAY()+30),$I2(TODAY()),$I20)").Int erior.ColorIndex = 36
.Add(xlExpression, , "=AND($I2<TODAY(),$I20)").Interior.ColorIndex = 38
End With
Range("a2:j2").Copy
Range("a2:j" & Range("a65000").End(xlUp).Row).PasteSpecial xlPasteFormats

"Josh O." wrote:

My apologizes for posting this twice...my browser closed down, I wasn't sure
that the post went through...

"Josh O." wrote:

I have the following VBA to enter, copy and paste conditional formats. But
it gets stuck at the first ".Add (xlExpression,...)" line.

This is what I want it to do:
If I2 is less than or equal to 60 from today and greater than 30 days from
today and A2 is not blank then highlight A2:J2 color 34...
Or
If I2 is less than or equal to 30 from today and greater than today and A2
is not blank then highlight A2:J2 color 36...
Or
If I2 is less today and A2 is not blank then highlight A2:J2 color 38 and
change font to white...
then copy formula down to last row.

Here is the current code:
With Range("a2:j2").FormatConditions
.Delete
.Add(xlExpression, ,
"=and($i2<=(today()+60),$i2(today()+30),$a2<"")" ).Interior.ColorIndex = 34
.Add(xlExpression, ,
"=and($i2<=(today()+30),$i2(today()),$a2<"")").I nterior.ColorIndex = 36
.Add(xlExpression, ,
"=and($i4<today(),$a2<"")").Interior.ColorInd ex = 38
End With
With Range("a2:j2")
.Copy
Range("a2:j" & Range("j65536").End(xlUp).Row).PasteSpecial
xlPasteFormats
End With


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
Capture conditional format as cell format Diddy Excel Discussion (Misc queries) 2 June 23rd 09 11:01 PM
New Conditional Format Overriding Previous Conditional Format Rene Excel Discussion (Misc queries) 3 February 27th 08 06:08 PM
Multiple conditional on conditional format formula Frank Kabel Excel Programming 1 July 27th 04 06:24 PM
Multiple conditional on conditional format formula Bob Phillips[_7_] Excel Programming 0 July 27th 04 05:30 PM
Keep format after paste from other worksheets - conditional format or EnableControl solution doesn't work No Name Excel Programming 0 May 3rd 04 12:22 PM


All times are GMT +1. The time now is 12:03 PM.

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

About Us

"It's about Microsoft Excel"