Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Run a procedure when any cell is activated (VBA/Excel2000/SP-3)

    I am certain that this is possible, but seem unable to find any reference to get me started.
    I will have a range of cells on a given page populated with text that I intend to use as a variable in a VBA procedure. I want the procedure to run each time any cell on that sheet is activated using the mouse.
    Any pointers will be greatly appreciated.
    Regards
    Don

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Run a procedure when any cell is activated (VBA/Excel2000/SP-3)

    You can use the Worksheet_SelectionChange event of the worksheet:
    - Right click the sheet tab of the worksheet.
    - Select View Code from the popup menu.
    - Select Worksheet from the Object dropdown list in the upper left corner of the module window.
    Excel creates the first and last lines of the event procedure for you:

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    End Sub

    In this procedure, Target represents the current selection in the worksheet. Note that this can consist of more than one cell. You can write code to do something with the selection.

  3. #3
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Run a procedure when any cell is activated (VBA/Excel2000/SP-3)

    Hans
    As usual, that was exactly what I was after.
    Regards
    Don

Posting Permissions

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