Consulting

Results 1 to 3 of 3

Thread: A toggle button to highlight/unhighlight cells with formulas

  1. #1
    VBAX Newbie
    Joined
    Jul 2008
    Posts
    5
    Location

    A toggle button to highlight/unhighlight cells with formulas

    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

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Sub HighlightFormulas()

    With Cells.SpecialCells(xlCellTypeFormulas).Interior

    If .ColorIndex = 6 Then

    .ColorIndex = xlColorIndexNone
    Else

    .ColorIndex = 6
    End If
    End With

    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Newbie
    Joined
    Jul 2008
    Posts
    5
    Location
    Works perfect! Thank you very much.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •