Can't Undo after cell change (worksheet_change)

mknowles

New Member
Joined
Jan 6, 2009
Messages
13
I'm sending data requests out for updating and would like to know which cells have been changed/updated. From the forums, I found the following VBA code which does what I want. What I've noticed is that if I modify a cell I don't want to, I can't undo it (Ctrl-Z doesn't work and Edit - Undo is grayed out). As someone not familiar with VBA, is there something in the code that prevents undo, or something else going on?

Private Sub Worksheet_Change(ByVal Target As Range)
Target.Interior.ColorIndex = 4
End Sub
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Thanks for the info. I've been messing around with the undo subroutine and have gotten it to work as written and following the example. I'm trying to adapt it to my spreadsheets and have a few questions.

1 -- Is sub ZeroRange necessary? It seems like it's only there to the change initially defined cells to 0. If the user changes a cell to a value other than 0, does ZeroRange need to be modified and retained?

2 -- Does sub UndoZero reference anything in ZeroRange? It seems to reference SaveRange but when I remove ZeroRange I get the "Can't undo" message box, which makes me think that ZeroRange is needed.

Thanks,
 
Upvote 0

Forum statistics

Threads
1,223,978
Messages
6,175,755
Members
452,667
Latest member
vanessavalentino83

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