View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Multiple Conditional Formatting in VB

Hi,

I forgot the white font so add this to the second condition

Selection.FormatConditions(1).Font.ColorIndex = 2

"Mike H" wrote:

Hi,

This works on the Range i1 to I 20 so change to suit

Sub sonic()
Sheets("Sheet1").Range("I1:I20").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=AND(I1<"""",I1<=A1+2)"
Selection.FormatConditions(1).Interior.ColorIndex = 4
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=AND(I1<"""",I1A1+2)"
Selection.FormatConditions(2).Interior.ColorIndex = 3
Range("I1").Select
End Sub

Mike

"Maver1ck666" wrote:

Hi Mike,

Thanks for that but I really need to know how to do this in VB as I have
about 6 different conditions I need. Sorry, I thought I had put that in but
obviously not.

Mav

"Mike H" wrote:

Hi,

Select the data in column I and try this

Format|Conditional Format
Select formula is
enter the formula

=AND(I1<"",I1<=A1+2)

Click Format|Patterns and select green

=AND(I1<"",I1A1+2)

and select red with white text

Mike
Click Add
Repeat the above but use the formula


"Maver1ck666" wrote:

Hi there,

I need to add a set of formats to a column but based on IF statements. For
example, I have column A (Date Raised) and column I (Date Acknowledged), I
want to be able to colour the cells based on what date was added to column I
e.g:

If I <= (A+2) then cell is green
If I (A+2) then cell is red with white text
If I is null then ignore

Can someone help with some code please.

Thanks in advance!!!

Mav