Function not Recognized

K

Ken

I am trying to use Chip Pearson's function to return the
color index of a cell:

Function CellColorIndex(InRange As Range, Optional _
OfText As Boolean = False) As Integer
'
' This function returns the ColorIndex value of a the
Interior
' (background) of a cell, or, if OfText is true, of the
Font in the cell.
'
Application.Volatile True
If OfText = True Then
CellColorIndex = InRange(1,1).Font.ColorIndex
Else
CellColorIndex = InRange(1,1).Interior.ColorIndex
End If

End Function

I have pasted the code into Sheet1.

In cell A1 I have set the background color to yellow.
In cell A2 I am trying to call the function with:

=CellColorIndex(A1,False)

I get the #NAME? error in A2. Looks to me like Excel is
not finding the function. Any ideas what I am doing wrong?

TIA.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top