formula off text colour

ajp

Board Regular
Joined
Nov 17, 2002
Messages
54
Hi,

If I have a cell (b1) where the text colour is say red, I would like a formula that puts a "R" in (c1).

I also have text that is green, blue.

I have tried @if function using b1=Selection.Font.ColorIndex = 3, but this doesn't work any ideas
:pray:
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Assuming the colors are not due to Conditional Formatting, which appears to be the case by your question, you will need a UDF to do what you want. Place the following code in a standard VBA module:

Function CellColor(rng As Range) As String
Select Case rng.Interior.ColorIndex
Case 3: CellColor = "Y"
Case 4: CellColor = "G"
Case 6: CellColor = "R"
Case 41: CellColor = "B"
Case Else: CellColor = ""
End Select
End Function


An example formula would be (assuming A1 contains color and you are entering the formula in cell B1):
=CellColor(A1)
 
Upvote 0
can't seems to get it to work. I have pasted formula and in module 1 but it doesn't seem to do anything

:cry:
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,243
Members
448,555
Latest member
RobertJones1986

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