ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Was Delete Key pressed? (https://www.excelbanter.com/excel-programming/333683-delete-key-pressed.html)

HLong

Was Delete Key pressed?
 
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.

Jim Thomlinson[_4_]

Was Delete Key pressed?
 
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.
--
HTH...

Jim Thomlinson


"HLong" wrote:

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.



All times are GMT +1. The time now is 10:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com