VBA Conditional Formatting - 4-7 conditions

Doodles1

New Member
Joined
Apr 21, 2011
Messages
2
Hi there,

I'm new to VBA and to be honest it scares me!

Basically I have a number of columns that need conditional formatting with more than the easy peasy three conditions.

Example 1

If CellValue >20 Cell needs to be filled Red (Colour Index 3)

If CellValue <-20 Cell needs to be filled Red (Colour Index 3)

If CellValue >10 Cell needs to be filled Light Orange (Colour Index 45)

If CellValue <-10 Cell needs to be filled Light Orange (Colour Index 45)

If CellValue <10 Cell needs to be filled Lime (Colour Index 43)

If CellValue >-10 Cell needs to be filled Lime (Colour Index 43)

If Cell is blank then there needs to be no fill.



Example 2

If CellValue >0.2 Cell needs to be filled Red (Colour Index 3)

If CellValue >0.1 Cell needs to be filled Light Orange (Colour Index 45)

If CellValue <0.1 Cell needs to be filled Lime (Colour Index 43)

If Cell is blank then there needs to be no fill.


The values in the cells (range = H2:H101 for Example 1 and P2:P101 for Example 2 are calculated by a formula or brought back using a VLOOKUP and are liable to change when data in the spreadsheet is refreshed.

I was using the nice and simple conditional formatting for Example 2 but I found that blank cells were being formatted to a Red fill!

Can anybody help me with some coding and save me from tearing any more of my hair out?!

Thank you!!!
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Welcome to the board.

You can do this with three conditions. One way:

1. Cell value is equal to ="" format with no fill
2. Formula Is =ABS(A1)>20 format red
3, Formula is =ABS($E$3)>10 format orange

Then format the cell as green.
 
Upvote 0
Hi,

Conditions 2 and 3 work well so thank you very much for that.

However the first condition doesn't appear to work and now blank cells are green rather than red.

Any other suggestions?

If anyone has some coding that I can amend to suit my conditions I'd be really interested to see it :0)
 
Upvote 0
Try

Condition1 : =ABS(A1)>20 - Format Red
Condition2 : =ABS(A1)>10 - Format Orange
Condition3 : =ABS(A1)>0 - Format Green
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,735
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top