You have to cancel the action with the variable given in 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 a dummy example:
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
Note that you wouldn’t have to set
False because it the default value (this is for the example purpose).