Hi everyone,
I need one of my cells to take a certain value based on another cell's background color that is assigned via conditional formatting. Finding a function that returns the colorindex of a cell was relatively easy - the problem is that this function returns -4142 when it comes accross conditionally formatted cells (which is the code for no fill), although the visible colorindex for that cell is 42.
Does anyone know how to make the below function work on cells colored via conditional formatting?
Many thanks,
Alex
Function ColorIndexOfOneCell(Cell As Range, OfText As Boolean) As Long
Dim CI As Long
Application.Volatile True
If OfText = True Then
CI = Cell(1, 1).Font.ColorIndex
ColorIndexOfOneCell = CI
Else
CI = Cell(1, 1).Interior.ColorIndex
ColorIndexOfOneCell = CI
End If
End Function
I need one of my cells to take a certain value based on another cell's background color that is assigned via conditional formatting. Finding a function that returns the colorindex of a cell was relatively easy - the problem is that this function returns -4142 when it comes accross conditionally formatted cells (which is the code for no fill), although the visible colorindex for that cell is 42.
Does anyone know how to make the below function work on cells colored via conditional formatting?
Many thanks,
Alex
Function ColorIndexOfOneCell(Cell As Range, OfText As Boolean) As Long
Dim CI As Long
Application.Volatile True
If OfText = True Then
CI = Cell(1, 1).Font.ColorIndex
ColorIndexOfOneCell = CI
Else
CI = Cell(1, 1).Interior.ColorIndex
ColorIndexOfOneCell = CI
End If
End Function