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, www.99excel.com
   Application.Volatile True
   If OfText = True Then
   CellColorIndex = InRange(1, 1).Font.ColorIndex
   Else
   CellColorIndex = InRange(1, 1).Interior.ColorIndex
   End If
End Function