Skip to main content

How to return background color of cell – Vba Code resolved

Copy & paste below VBA code in your Module & use function “=CellColorIndex(A2)” in sheet.


Function CellColorIndex(InRange As Range, Optional OfText As Boolean = False) As Integer
   ‘This Code created by Akumar,
   Application.Volatile True
   If OfText = True Then
   CellColorIndex = InRange(1, 1).Font.ColorIndex
   CellColorIndex = InRange(1, 1).Interior.ColorIndex
   End If
End Function