PDA

View Full Version : A toggle button to highlight/unhighlight cells with formulas



Belinda
02-06-2009, 03:55 PM
Hello,

I have macro button that will highlight "cells with formulas" with a yellow background color.
How do I modify the macro so that when I click the button again, it will unhighlight the selected cells?

Sub HighlightFormulas

Cells.SpecialCells(xlCellTypeFormulas).Select
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With

End Sub

Thank you

Bob Phillips
02-06-2009, 04:11 PM
Sub HighlightFormulas()

With Cells.SpecialCells(xlCellTypeFormulas).Interior

If .ColorIndex = 6 Then

.ColorIndex = xlColorIndexNone
Else

.ColorIndex = 6
End If
End With

End Sub

Belinda
02-09-2009, 03:23 PM
Works perfect! Thank you very much.