Color coding excel cells using VBA

Hitesh_Banda

New Member
Joined
Jun 8, 2010
Messages
25
Hi All,

I have a excel sheet which has conditional formatting in the cells N2 to P2 (and all cells below that), which changes their interior color to Red, Yellw and Green. (interior.color = 255, 65535 and 5287936 respectively)

Now I want to change the color of R2 and below cells (which can be done using a loop, thats no problem) depending on the colors of the cells N2 to P2 in following way.

1. 3+ Red- RED
2. 2+ Red- Amber
3. 3+ Amber- Amber
4. Rest- Green.

Can anyone put some light how I can change color of a cell depending on the color of other cells?

Thanks.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
You can't (easily) test the colour of a cell which has been set by conditional formatting. If you want to know the colour of a cell that has been set by conditional formatting, then you have to test the condition which caused the formatting.

For example, if you have a cell which is normally white, but turns red when its value exceeds 99, it will always look white to VBA. If VBA wants to check if it's red, it needs to check whether its value exceeds 99.

Have I explained clearly?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,527
Messages
6,114,142
Members
448,551
Latest member
Sienna de Souza

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