You must undo the action with the variable specified in the argument:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) MsgBox "a cell was clicked!", vbOKOnly, "a click" 'Disable standard behavior Cancel = True End Sub
Here is an example of a mannequin:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) Dim response As Variant response = MsgBox("Are you sure you want to edit the cell?", vbYesNo, "Check") If response = vbYes Then Cancel = False Else Cancel = True End If End Sub
Please note that you do not need to set Cancel to False , because this is the default value (this is for example).
source share