Retrieve Interior Cell Color Name or Index

Ever wanted to know the name of a cell color? Or perhaps the index number so you could add interior cell color through code? This function retrieves the cell color and index number for the target cell.

^ Cells colored by conditional formatting will not work;the cells must have an interior color. o

CellColor (myCell, ColorIndex) The arguments are myCell—The target cell.

ColorIndex—Optional; by default, the Color Name is returned, but if this is set to True, the Index number is returned instead.

Function example:

Function CellColor(myCell As Range, Optional Colorlndex As Boolean) Dim myColor As String, IndexNum As Integer

Select Case myCell.Interior.Colorlndex Case 1

myColor =


IndexNum =

0 0

Post a comment