Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Multiple Conditional Formatting in VB

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Multiple Conditional Formatting in VB

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Multiple Conditional Formatting in VB

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Multiple Conditional Formatting in VB

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Multiple Conditional Formatting in VB

Sorry Mike,

I think im going mad.

I have copied your code but it doesn't seem to update the cells. Any ideas
please?

Mav

"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

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Multiple Conditional Formatting in VB

I wrote it so it could go in as worksheet code or in a module so I would
suggest you right click the sheet, view code and paste this in and try and
run it again. I've added another line so I suggest you use this version.

When you say cells aren't changing that may suggest that what you think are
dates may not be so check they are. For a date in A1 type =a1+1 in another
cell and see what you get, it should add 1 day to the date in a1 provided the
date is really a date.

lastly select I1 and click format|Confitional format and check if the macro
has entered the formats etc. If it has then It's fairly certain you hava a
data type issue.

Sub sonic()
Sheets("Sheet1").Range("I1:I20").Select
Selection.FormatConditions.Delete
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
Selection.FormatConditions(1).Font.ColorIndex = 2
Range("I1").Select
End Sub


Mike


"Maver1ck666" wrote:

Sorry Mike,

I think im going mad.

I have copied your code but it doesn't seem to update the cells. Any ideas
please?

Mav

"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

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Multiple Conditional Formatting in VB

On Apr 18, 2:11*pm, 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- Hide quoted text -


- Show quoted text -


Hi,

If you are using a version less than Excel 2007 then you can't have
more than 4 conditions (1 default and 3 defined) in Conditional
Formatting.

Anant
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
Multiple Conditional Formatting-HELP Cindy Excel Discussion (Misc queries) 2 January 22nd 10 08:07 PM
Conditional Formatting with multiple spreadsheets Jacob Nordman Excel Discussion (Misc queries) 0 January 23rd 08 01:44 AM
Multiple Conditional Formatting Bec[_3_] Excel Discussion (Misc queries) 1 August 17th 07 07:40 AM
multiple conditional formatting Robin Krupp Excel Worksheet Functions 0 September 11th 06 04:13 PM
Multiple Conditional Formatting Using VBA jennie Excel Programming 7 March 2nd 04 12:50 PM


All times are GMT +1. The time now is 03:04 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"