excel VBA if background color then

Ferlucia

New Member
Joined
Jul 3, 2014
Messages
43
Hello everyone,

I'm trying to create a VBA code that works with background color and does:

IF all filled cells in a row (starting from column F) have a green background then the correspondig cell in D gets a green backgroud.
IF 1 or more (but not all) filled cells in a row (starting from column F) have a green background then the corresponding cell in D gets a yellow background.
IF none of the filled cells in a row (starting from column F) have a green background then the corresponding cell in D stays white.

The amount of filled cells per row is VARIABLE
This code should only start from row 4 and down

Hope you can help
 
It still doesn't work...

Maybe I'm doing something wrong?

I tried connecting it to a button, but for some reason I can't add any buttons...
Some questions...

1) What kind of button did you try to add... a Forms button or an ActiveX button?

2) Where did you install the code (did you see JoeMo's installation note in Message #9)?

3) Are you sure the color numbers you posted in Message #7 are correct? Select one of your green cells and then execute this statement in the VBA Immediate Window and tell us the number that gets printed out...

? Selection.Interior.Color
 
Upvote 0

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
I followed the steps from JoeMo's post and it works :)

I'm still new at this and sometimes I forget the most obvious things :oops:

So thank you Rick Rothstein for your code
And thanks JoeMo for your step by step explanation

Thanks for your time and help :)
 
Upvote 0

Forum statistics

Threads
1,215,102
Messages
6,123,099
Members
449,096
Latest member
provoking

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