Results 1 to 2 of 2

Thread: Change cell background on click

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2004
    Posts
    1

    Question Change cell background on click

    I need to have an excel spreadsheet cells' fill color change when a user clicks in the cell. Can this be done. The cell contents don't change only the fill color?
    Invisible buttons on each cell? a UDF? any ideas or thoughts?

    TIA
    Hammertime

  2. #2
    Addicted Member
    Join Date
    Dec 2001
    Posts
    158
    Go into the Visual Basic Editor.

    Double click one of the worksheet items under "Microsoft Excel Objects".

    Add this code:

    Code:
    Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
        With Selection.Interior
            .ColorIndex = 6
            .Pattern = xlSolid
        End With
    End Sub
    Every time a cell is clicked on, that will go off and change the cell interior color to yellow.


    BTW: I should probably mention if you click and drag a range that will paint the whole range. You can make it check the range for mult-cell selections and not paint if you want to.
    Last edited by Garratt; May 2nd, 2004 at 09:10 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width