View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Another Question

You can only do that with VBA code. For example,

Public Function ColorIndexOfCell(Rng As Range, _
Optional OfFont As Boolean = False) As Variant
Application.Volatile True
If Rng.Cells.Count 1 Then
ColorIndexOfCell = CVErr(xlErrRef)
Else
If OfFont = True Then
ColorIndexOfCell = Rng.Font.ColorIndex
Else
ColorIndexOfCell = Rng.Interior.ColorIndex
End If
End If
End Function

This will return the ColorIndex (a value between 1 and 56, or
xlColorIndexAutomatic = -4105 or xlColorIndexNone = -4142) of the specified
cell. If the OfFont parameter is True, the function return the ColorIndex of
the font. If OfFont is omitted or False, it return the ColorIndex of the
fill. You can then call this function from a worksheet cell with a formula
like

=ColorIndexOfCell(A1,FALSE) = 5

to return TRUE or FALSE indicating whether A1 has a fill color of 5 =
default blue.

See www.cpearson.com/excel/colors.htm for more info.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"Kris79" wrote in message
oups.com...
Is it possible to write an if function on a background color. Say if
a1 has a background color of red return 1 if true and return 0 if
false.