Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Private Sub Worksheet_SelectionChange

  1. #1
    Board Regular
    Join Date
    Apr 2002
    Posts
    107
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Is there similar code that will kick off a macro when any cell is selected in any worksheet in the entire workbook? Since new sheets will be added at any time, I cannot simply add the above Private Sub to all current worksheets.

    I am looking for something like:

    Private Sub Workbook_SelectionChange(ByVal Target As Excel.Range)

    (although i know the above does not actually exist)

  2. #2
    MrExcel MVP Tom Urtis's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, California USA
    Posts
    11,162
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    You were close. The code line is

    Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)

  3. #3
    MrExcel MVP
    Colo's Avatar
    Join Date
    Mar 2002
    Location
    Kobe, Japan
    Posts
    1,456
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    2 Thread(s)

    Default

    Hi. Please copy this into a ThisWorkbook module.
    The event you want is already exist.


    Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range)
    MsgBox Sh.Name & " " & Target.Address(0, 0) & " are selected"
    End Sub

    Hope this helps + pen pineapple apple pen!

    Masaru Kaji aka Colo - cellmasters.net

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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