If Statement W/ Colour

Jose Miguel

Board Regular
Joined
Feb 3, 2005
Messages
99
Hello All,

Quick question. I have the following.
Real One to Look at for PHSA.xls
ABCDEF
22722624270-225CONTNR COOLER LABTOP .32 PLACE
22822724270-226COOLER UNIT NALGENE 12-TUBE
22922824710-10289000-252CYL GRAD CLASS B CALBRTD "TO DELIVER" 50ML
23022924710-12489000-254CYL GRADUATED PYREX TC 100ML
23123024710-240KT481755-0100CYL GRADUATED
23223124710-249KT481755-1000CYL GRADUATED SNGL METRIC SCALE
23323224710-340CYL GRADUATED PYREX 250ML
23423324774-785CYL GRAD PMP 2L
Replacement and Discontinued


I want to try to achieve the following:

If C is green, then "x" in D1
If C is yellow then "C1" in E1
If C is blank then do nothing

I can't wrap my brain around creating If statements using colour backgrounds as conditions. Could someone kindly help? Thank you.

Jose
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hello Joe Was,

I'll look into the VBA code if all else fails, but how would I specify the colour of the text as a condition, and what would be the outcome format? Thanks.

Jose
 
Upvote 0
If your interior cell colors are the lightest Yellow and the lightest green from the cell color utility pallet, then this code will work from any code module. To make it run automatically change this Sub to a Change Event!

This code will do what you want for every cell in column C.

To use conditional formatting you will find getting the right formula a problem, for color you will be limited to detevting Font color and not Cell coloe as: [Red] to indicate the font color and I seldom use Conditional Formatting, it is too limited and the formula code uses a different syntax that is difficult to work out more offten than not. I use VBA code:


Sub colorTest()
Dim myBot&, myRng As Range

myBot = Range("C65536").End(xlUp).Row

Set myRng = Range(Cells(1, 3), Cells(myBot, 3))

For Each c In myRng
If c.Interior.ColorIndex = 35 Then c.Offset(0, 1).Value = "x"
If c.Interior.ColorIndex = 36 Then c.Offset(0, 1).Value = c.Offset(0, 2).Value
Next c

End Sub
 
Upvote 0
Perhaps another way of looking at this might be better...

How are the cloured cells being coloured?

If you are using conditional formatting it should be easy to use the same conditions to provide the results you want...

If you are currently not using conditional formatting, and are colouring the cells manually... then perhaps you should use conditional formatting...

You could, for example, enter x in D1 and use this a condition to turn C1 Green...

Would this approach work? If so we can refine it to get what you want.

Regards,

Simsy
 
Upvote 0

Forum statistics

Threads
1,203,241
Messages
6,054,327
Members
444,717
Latest member
melindanegron

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