vbaexcelmodifier-key

Use Ctrl as modifier on Worksheet_SelectionChange


I would like to open a form when a locked cell is clicked in a specific way (double click, key modifiers, etc).

If I use Worksheet_BeforeDoubleClick, it will show a warning after closing the form, stating that the cell is locked (which is annoyting).

If I use Worksheet_SelectionChange, no warning will appear, but the form will appear every time a cell is selected (which is a bit much).

Is there anyway to use a modifier, like Ctrl, combined with Worksheet_SelectionChange, so that the user has to make an active choice to open the form?


Solution

  • Just set Cancel = True at the end of your Worksheet_BeforeDoubleClick sub.

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