+ Reply to Thread
Results 1 to 3 of 3

Run macro on double click only

Hybrid View

  1. #1
    Registered User
    Join Date
    12-05-2005
    Location
    WA
    Posts
    83

    Run macro on double click only

    Let's say I have an item that I want to select with one click, and run a macro with a second click. How can this be done?

  2. #2
    Bob Phillips
    Guest

    Re: Run macro on double click only

    Use the double-click event

    Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _
    Cancel As Boolean)
    ... your code here
    End Sub

    This is worksheet event code, which means that it needs to be
    placed in the appropriate worksheet code module, not a standard
    code module. To do this, right-click on the sheet tab, select
    the View Code option from the menu, and paste the code in.


    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "famdamly" <famdamly.23vkwm_1141022400.6677@excelforum-nospam.com> wrote in
    message news:famdamly.23vkwm_1141022400.6677@excelforum-nospam.com...
    >
    > Let's say I have an item that I want to select with one click, and run a
    > macro with a second click. How can this be done?
    >
    >
    > --
    > famdamly
    > ------------------------------------------------------------------------
    > famdamly's Profile:

    http://www.excelforum.com/member.php...o&userid=29382
    > View this thread: http://www.excelforum.com/showthread...hreadid=516789
    >




  3. #3
    Dave Peterson
    Guest

    Re: Run macro on double click only

    I think Bob meant:

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
    Cancel As Boolean)

    Cancel = true

    'your code here

    End sub


    If you have "tools|options|edit tab|edit directly in cell" checked, then the
    "Cancel = true" tells excel to not edit the cell.

    Bob Phillips wrote:
    >
    > Use the double-click event
    >
    > Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _
    > Cancel As Boolean)
    > ... your code here
    > End Sub
    >
    > This is worksheet event code, which means that it needs to be
    > placed in the appropriate worksheet code module, not a standard
    > code module. To do this, right-click on the sheet tab, select
    > the View Code option from the menu, and paste the code in.
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > (remove nothere from email address if mailing direct)
    >
    > "famdamly" <famdamly.23vkwm_1141022400.6677@excelforum-nospam.com> wrote in
    > message news:famdamly.23vkwm_1141022400.6677@excelforum-nospam.com...
    > >
    > > Let's say I have an item that I want to select with one click, and run a
    > > macro with a second click. How can this be done?
    > >
    > >
    > > --
    > > famdamly
    > > ------------------------------------------------------------------------
    > > famdamly's Profile:

    > http://www.excelforum.com/member.php...o&userid=29382
    > > View this thread: http://www.excelforum.com/showthread...hreadid=516789
    > >


    --

    Dave Peterson

+ Reply to Thread

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