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
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Try adding to "Double _Click "Event.
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
End Sub
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0
With the add-in installed, in the immediete window, type ?Application.EnableEvents and press the enter key. See if it returns False.
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,388
Members
448,957
Latest member
Hat4Life

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