Canceling A Double Click Event

RobExcel

Board Regular
Joined
Jan 6, 2010
Messages
69
I'm using Excel 2007 on Win7.

I'd like to run some code if the user double clicks in certain cells. However, I don't want the double click to make Excel go into Edit mode. (It's annoying and interferes with the code that runs.)

Yesterday, I was able to do this by adding the line "Cancel = True" to my VBA.

Today, Excel doesn't seem to recognize the Cancel command. I've replicated this by opening a new workbook and adding the following code to Sheet1:

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
End Sub

This does not prevent Excel from going into edit mode. Does anyone have a solution? Can others replicate the issue?

I assume that some setting/option has changed in my copy of Excel or that Microsoft released a patch, I just have no idea what it could be.

Thanks
Rob
 

Some videos you may like

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841
Try adding to "Double _Click "Event.
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
End Sub
 

RobExcel

Board Regular
Joined
Jan 6, 2010
Messages
69
Sorry, that was a type-o in the post, not what I was actually doing.

I can re-create the issue by putting this code in:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
End Sub
 

RobExcel

Board Regular
Joined
Jan 6, 2010
Messages
69
While I don't understand it, I've now found that if I uninstall a particular commercial add-in, then reboot, and open the document again, the problem goes away.
 

GTO

MrExcel MVP
Joined
Dec 9, 2008
Messages
6,154
With the add-in installed, in the immediete window, type ?Application.EnableEvents and press the enter key. See if it returns False.
 

RobExcel

Board Regular
Joined
Jan 6, 2010
Messages
69
No, events are enabled. I did find a class event that fires before a double click. The code is scrambled, so I can't read much of it, but I can tell that cancel is not set to true or false. I'm guessing that somehow Excel is remembering the custom class double click event's cancel and not my workbook specific one.

Oddly, I see that they also have a before right click event; however, I can get that one to work just fine.

I've worked around this by forcing an uninstall of the add-in.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,054
Messages
5,599,533
Members
414,315
Latest member
Yolanda5050

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
Top