Was Delete Key pressed?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The user selects a cell and presses the delete key. Now, would it be possible
to determine if the user pressed the delete key on the SheetChange event
handler? I tried the GetKeyState function. It works fine the first time,
but after the function always returns positive, the key has been pressed. My
intension is to determine if the user is deleting the content on a cell. If
it is true, then the routine deletes the contents of other cells on the
sheet.
 
Why not just check the contents of the cell at the change event. If the cell
is blank then...

Private Sub Worksheet_Change(ByVal Target As Range)
If Trim(Target.Value) = Empty Then
MsgBox "Empty Cell"
End If
End Sub

This catches both delete and backspace.
 
Back
Top