View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Kris79 Kris79 is offline
external usenet poster
 
Posts: 8
Default Another Question

On Feb 24, 2:18�pm, "Chip Pearson" wrote:
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.

Seewww.cpearson.com/excel/colors.htmfor more info.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLCwww.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.- Hide quoted text -


- Show quoted text -


VBA is my weekpoint i have no clue what that means or how to get it to
relate to what i am trying to do.