Was Delete Key pressed?

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.
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top