View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Francois via OfficeKB.com
 
Posts: n/a
Default function to extract background color from one cell to another

Bob Phillips wrote:
VBA?

iLastRow = Cells(Rows.Count).End(xlUp).Row
For i = 1 To iLastRow
Cells(i,"C").Interior.Colorindex = Cells(i,"A").Interior.Colorindex
Next i

this copies the colour from A to C

Hi all,
Doe's anyone know if a function/addin etc exists that will enable me to get

[quoted text clipped - 11 lines]
Thanks to all who have helped me on previous posts.....even if you didn't
know you had !






Hi Bob,

Thanks for the very quick reply.

The destination cells for this 'function' are on a 'status' worksheet, which
lists data from several other worksheets, so I don't believe that I could use
VBA easily.
I found this from Chip Pearsons site but I'm having trouble getting it to
work (I'm sure it's me)


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

But when I put the range in (A1:T90) or whatever I got some sort of
compile/syntax error on the Function line.
as I say , I know it's me but as you may guess I'm not clued up on much of
VBA

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200603/1