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

Thread: Starting Marco

  1. #1
    Board Regular
    Join Date
    Apr 2002
    Location
    Puerto Vallarta, Mexico
    Posts
    869
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Is there a way to cause a certian macro to run when a cell is selected. Example, When Cell B2 is selected, either by direct selection or by tabbing, execute a macro named "ShowBusy"? This would be rather helpfull to me if anyone knows of a way. Thanks.......ElGringo

  2. #2
    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 ElGringo.
    Right click on the sheet tab, select View Code and Please copy this into there.


    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Address(0, 0) = "B2" Then ShowBusy
    End Sub

  3. #3
    Board Regular
    Join Date
    Apr 2002
    Location
    Puerto Vallarta, Mexico
    Posts
    869
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Pretty fantastic. Does just what I want. Can I put more than one entry so that various cells can start various macros?
    Again, Thanks a Million

  4. #4
    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.
    If you have various macros named "Shushi","Tenpura","Ninja".....
    An easy way to execute more than one entry is to use "Select Case" method.

    Here is a sample.


    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Count > 1 Then Exit Sub
    Select Case Target.Address(0, 0)
    Case "B2"
    Shushi
    Case "B3"
    tenpura
    Case "B4"
    ninja
    End Select
    End Sub

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
  •