Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 3 of 3

Thread: Run Macro By Double-Clicking Cell

  1. #1
    Join Date
    10th August 2006
    Posts
    18

    Run Macro By Double-Clicking Cell

    Is there a way to enable a macro by double-clicking a cell?

    Currently, I'm running an AutoFilter macro that automatically references a second sheet when the specific cell is selected. The problem is that when a user does a search for an item (Ctrl+F), the macro will immediately initiate and refer to the other cell which confuses the user.

    Ideally, I want the macro to be initiated ONLY when the user DOUBLE-CLICKS on the cell.

    Here's the code that I'm using:

    VB:
    Private Sub Worksheet_SelectionChange(ByVal Target As Range) 
        If Target.Column = 1 And Target.Row <= Cells(Rows.Count, 1).End(xlUp).Row Then 
            Application.EnableEvents = False 
            On Error Resume Next 
            Worksheets("Worksheet").howAllData 
            Worksheets("Worksheet").Range("A1:A4231").AutoFilter Field:=2, Criteria1:=Target 
            Worksheets("Worksheet").Activate 
            Application.EnableEvents = True 
        End If 
    End Sub 
    
    
    Thanks in advance.
    Last edited by Dave Hawley; December 27th, 2006 at 08:54.

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    24th January 2003
    Location
    Australia
    Posts
    31,716

    Re: Enable An Macro By Double-clicking A Cell

    Use the Worksheet_BeforeDoubleClick Event.

    VB:
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) 
         'your code
    End Sub 
    
    
    Cancel=True means the double click for the Target doesn't go into Edit mode.
    Last edited by Dave Hawley; December 27th, 2006 at 08:57.

  3. #3
    Join Date
    10th August 2006
    Posts
    18

    Re: Run Macro By Double-Clicking Cell

    Thank you! Works perfectly.

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

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

Possible Answers

  1. Double Clicking On Cells Slowing Down Work
    By johno359 in forum EXCEL HELP
    Replies: 6
    Last Post: May 25th, 2007, 22:48
  2. Change color of cell by double clicking??
    By harryco79 in forum EXCEL HELP
    Replies: 2
    Last Post: June 5th, 2005, 09:07
  3. Text box req by double clicking cell
    By Excelman in forum EXCEL HELP
    Replies: 1
    Last Post: March 11th, 2005, 20:53
  4. I can't open excel file by double clicking
    By Hubinski in forum EXCEL HELP
    Replies: 5
    Last Post: October 31st, 2003, 04:31

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
  •  
porno