Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel - start macro by doubleclicking cell 1

Status
Not open for further replies.

48Highlander

Technical User
Joined
Feb 8, 2004
Messages
119
Location
CA
Is there some way I can achieve this?

Bill J
 


Hi,

Take a look at Worksheet Events in the VB Editor.

Skip,

[glasses] [red]Be Advised![/red] For those this winter, caught in Arctic-like calamity, be consoled...
Many are cold, but few are frozen![tongue]
 
Thanks Skip. I have the following code in the sheet module:

Code:
Private Sub Worksheet_SheetBeforeDoubleClick(ByVal Sh As Object, _
        ByVal Target As Range, ByVal Cancel As Boolean)


    MsgBox "Test"
    Cancel = True

End Sub

When I double-click a cell in the worksheet, nothing happens. What am I not seeing?

Bill J
 
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Application.EnableEvents = False
    MsgBox "test"
    Cancel = True
Application.EnableEvents = False
End Sub

Regards
Ken...........


----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]
----------------------------------------------------------------------------
 
I tried adding both
Application.EnableEvents = True
and
Application.EnableEvents = False

to my code but this sheet module still does not work when I double click on it.




Bill J
 


Your code is NOT in the worksheet object.

It's in the ThisWorkbook object.

RIght click the sheet tab and select View Code.

Select the BeforeDoubleclick Event and put your 2 lins of code in there
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    MsgBox "Test"
    Cancel = True
End Sub

Skip,

[glasses] [red]Be Advised![/red] For those this winter, caught in Arctic-like calamity, be consoled...
Many are cold, but few are frozen![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top