Worksheet KeyPress event

bujubenji

New Member
Joined
Feb 26, 2023
Messages
12
Office Version
  1. 365
Platform
  1. Windows
Hi all,

This might be a basic one, but is it possible to trigger a vba event if cells on a worksheet are cleared? To provide a little context, a have a userform that will drop data into columns B:E starting on row 44. The next entry would be row 45 and so on. I have a macro in place on a shape acting as a button, which will copy that data over to the next clear row in columns H:K when the product has been sent to Quality Assurance. If that button is pressed again, the data that was sent over will be cleared and subsequent data will be shifted up.

However, I also want to make it so that if data is cleared from a row in columns H:K by pressing delete, subsequent data will move up into the now cleared cells.

The shift up component is fine and works as part of the aforementioned macro that clears cells: (Range("H44:K58").SpecialCells(xlCellTypeBlanks).Delete Shift:=xlShiftUp)

Would an easier solution just be protecting the cells with something like the following?:

"Dim Sh As Worksheet
For Each Sh In Worksheets
Sh.Protect userinterfaceonly:=True
Next

End Sub"

Many thanks,

Ben
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
if you want reliable data, better make sure data can be manipulated in a controlled fashion - protect the sheets.
other people actions are too unpredictable.
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,953
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top