This doesn't incorporate your flag so adjust if you need that.

Select either a single cell to get formulas in whole sheet or a selection of
cells.

Sub ToggleFormulaColour()
Dim rng As Range, vFntClrIdx

On Error Resume Next
Set rng = Selection.SpecialCells(xlCellTypeFormulas, 23)
On Error GoTo errH
If rng Is Nothing Then
MsgBox "No Formulas"
Else

vFntClrIdx = rng.Font.ColorIndex
If IsNull(vFntClrIdx) Then vFntClrIdx = -1

If vFntClrIdx > 0 Then
vFntClrIdx = xlAutomatic
Else
vFntClrIdx = 5 'blue in a default palette
End If

rng.Font.ColorIndex = vFntClrIdx
End If

errH:

End Sub

Note SpecialCells in VBA fails if a little over 8000 discontiguous areas are
involved.

Also try Ctrl-`¬¦ the key under Esc.

Regards,
Peter T


"DoctorG" <DoctorG@discussions.microsoft.com> wrote in message
news:8156FB93-13F4-4DA4-ABB9-D1ED7F7F5373@microsoft.com...
> I want to create an On/Off button that will temporarily show which cells
> contain formulas.
>
> If someone knows a better way pls say so.
>
> I thought of adding and then subtracting a fixed number from the
> Interior.color property but I don't know how to retrieve the current

value.
>
> rngFormulas.Select
> If flag = False Then
> With Selection.Interior
> .ColorIndex = ????? + 300000
> End With
> flag = True
> Else
> With Selection.Interior
> .ColorIndex = ????? - 300000
> End With
> flag = False
> End If
>