ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cell ForeColor (https://www.excelbanter.com/excel-programming/304414-cell-forecolor.html)

JohnZing

Cell ForeColor
 
Hi,

i need some ideas to implement a formula like ...

=IF(CellForeColor(D2)=RGB(255,0,0),"R","B")

if cell D2 text color is Red then the value will be "R", "B" if not.

thank you

Carl Brehm

Cell ForeColor
 
Function CHECKCOLOR(CL As Range) As String
Dim NUM As Integer


NUM = CL.Interior.ColorIndex
Select Case NUM
Case 6
CHECKCOLOR = "Y" 'YELLOW
Case 5
CHECKCOLOR = "B" 'BLUE
Case 46
CHECKCOLOR = "R" 'RED
Case Else
CHECKCOLOR = ""
End Select

End Function

= checkcolor(d2)
If you change a color you will have to force a calculation with Ctrl-Alt-F9
--
Carl & Linda Brehm
Lake Lafourche Bird House
Hebert, LA

Keets, Tiels, GN Lories, Quakers
Mitred Conures, TAG's, Bourkes
Lovebirds, Cherry Head Conures
Prince of Whales

Wholesale Cages to Breeders & Pet Stores
"JohnZing" wrote in message
...
Hi,

i need some ideas to implement a formula like ...

=IF(CellForeColor(D2)=RGB(255,0,0),"R","B")

if cell D2 text color is Red then the value will be "R", "B" if not.

thank you



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.717 / Virus Database: 473 - Release Date: 07/08/2004



John Zing

Cell ForeColor
 
thank you for your reply, but your code work well with cell background.
I need to evaluate the text color.

Carl Brehm said the following:
Function CHECKCOLOR(CL As Range) As String
Dim NUM As Integer


NUM = CL.Interior.ColorIndex
Select Case NUM
Case 6
CHECKCOLOR = "Y" 'YELLOW
Case 5
CHECKCOLOR = "B" 'BLUE
Case 46
CHECKCOLOR = "R" 'RED
Case Else
CHECKCOLOR = ""
End Select

End Function

= checkcolor(d2)
If you change a color you will have to force a calculation with Ctrl-Alt-F9



All times are GMT +1. The time now is 08:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com