Custom HTML Module

Sub FontColorFormulas1()
‘Code for different font color in cells having formulas, formulas and numbers and constants. _
Run this code to change font colors in Used Range in Active Sheet.

Dim formulaColor As Long
Dim formulanumbersColor As Long
Dim constantColor As Long
Dim cell As Range

formulaColor = RGB(Red:=0, Green:=255, Blue:=0)
formulanumbersColor = RGB(Red:=0, Green:=0, Blue:=0)
constantColor = RGB(Red:=0, Green:=0, Blue:=255)

‘color cells having formulas
For Each cell In ActiveSheet.UsedRange.SpecialCells(xlCellTypeFormulas)
cell.Font.Color = formulaColor
Next cell

‘color cells having formulas and having nos.
For Each cell In ActiveSheet.UsedRange.SpecialCells(xlCellTypeFormulas, xlNumbers)
cell.Font.Color = formulanumbersColor
Next cell

‘color cells having constants (non-formulas)
For Each cell In ActiveSheet.UsedRange.SpecialCells(xlCellTypeConstants)
cell.Font.Color = constantColor
Next cell

End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top