VBA code for If statement that recognized background color

PerunPL

New Member
Joined
Jun 18, 2018
Messages
6
Hey guys, so I’m looking for VBA function code that could help me with if statement based on active cell background color. So what I mean by that is let’s say: if active cell q8 is blue and if D8 says “ blue ” or “green”copy number from J8.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Welcome to the forum.

Assuming you are using Excel 2010 or later, you can use the DisplayFormat.Interior.Color property of the cell (if the colour is applied by conditional formatting) or just the Interior.Color property if it's a manually applied colour. You'd need to test that against the correct RGB value since there are a lot of different shades of blue! ;)
 
Upvote 0
RoryA my blue color is RGB(0,176,240)
So what I’m trying to do is write VBA function that could read that background color of the active cell and if so copy number from specific cell since as of now my excel function is = If( AND( D2= “ S-1” or “S-2” or” S-3”, M2=“ blue”), J2,). So I’m just trying to write code that could help me simplify this function instead writing blue on the side of my table, to just read the color and still apply If statement.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,154
Members
453,021
Latest member
Justyna P

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