Question about Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

Photomofo

Active Member
Joined
Aug 20, 2012
Messages
259
I would like to have it so that when you double click on a cell (any cell in my workbook) you trigger an event. I've tried all of these but none of them work. Is there a security setting in Excel that may be blocking this type of code?


VBA Code:
Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Stop
End Sub


Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
   If Sh.Name <> "Data" Then Exit Sub
   Cancel = True
   Global_Filter
End Sub


Private Sub Workbook_SheetBeforeDoubleClick_2(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
   If Sh.Name <> "Data" Then Exit Sub
   Cancel = True
   If Not Intersect(Target, Sh.Range("A1:F1")) Is Nothing Then
      Global_Filter
   ElseIf Target.Address(0, 0) = "J1" Then
      Sh.ShowAllData
   End If
End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Have you accidentally disabled events?

If so, you can re-enable them by manually running this code:
VBA Code:
Sub ReEnableEvents()
    Application.EnableEvents = True
End Sub

Also note that in order for Event Procedure VBA code to run automatically, it MUST be placed in the appropriate modules (i.e. Sheet code needs to go in the Sheet modules, Workbook code needs to go in the "ThisWorkbook" module).
 
Upvote 0
Solution
You are welcome.
Glad I was able to help!
 
Upvote 0

Forum statistics

Threads
1,214,645
Messages
6,120,711
Members
448,984
Latest member
foxpro

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top