Results 1 to 2 of 2

Run macro on cell double click! - Half way there

Threaded View

  1. #1
    Registered User
    Join Date
    04-08-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    2

    Run macro on cell double click! - Half way there

    Okay so I have two rows of yes/no cells and I would like to run a specific macro based on which cell was double clicked(yes/no)

    Problem is, the code I found runs no matter where I double click

    Heres the code I have:

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) 
        Call MyMacro 
    End Sub
    This macro should only run for one specific sheet, as other sheets will have macros like this on running(same setup of sheets for different info)

    Yes No Info 1
    Yes No Info 2
    Yes No Info 3

    How can I define my function so that it only run when I double click in a specific range.

    FYI: My macro is relative so it will change based on which box I click

    =-=-==-==-=-=-=-=-=--==-=--==--=-=-==--==-=--==-
    Edit:

    I figured it out!

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
        If Target.Column = 1 Then
            Call macro1
            ElseIf Target.Column = 2 Then
            Call macro2
            End If
            
    End Sub
    make sure to put it in the sheet and not the module window!
    Last edited by jlab89; 04-09-2012 at 12:32 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1