Hi,
I have a reset button in my worksheet and I added a UNDO button. Can you please create a code for me for the undo button. Thank you :o)
Please Login or Register to view this content.
Hi,
I have a reset button in my worksheet and I added a UNDO button. Can you please create a code for me for the undo button. Thank you :o)
Please Login or Register to view this content.
Hi,
Let me clarify. The reset button is to clear the A13-AE34 and AN13-AS34 cells. If for some reason I accidentally reset those cells, I want to be able to "undo" and bring those data back to the worksheet.
Thanks.
You will have to store values some how, before you clear them. Be it array, dictionary, or workbook.
Simplest method is to save a copy of workbook before you clear data, and copy them back in with undo.
Ex:
Edit: Should have tested ErrHandle. Changed code to check if backup exist before executing rest of the code.Please Login or Register to view this content.
Edit2: You may want to add code to delete backup after Undo is pressed.
Last edited by CK76; 01-09-2019 at 04:12 PM.
?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
― Robert A. Heinlein
Hi,
Is there any simple code like my reset code.
Like this:
Sub Undo_Click()
[A13:AE34,AN13:AS34].Value = ""
End Sub
I am not too familiar with the vba code so I thought it will be easier :o)
thanks.
No. You can't undo action done by VBA. As whenever any code runs, it wipes undo cache.
Alternate approach is to store values in memory and put it back to sheet when Undo is pressed. However, that will require just as much (or more) coding as above
Great! Thank you.
Hi,
I added 2 more worksheet. I name the worksheet Page 1 and Page 2. Can you please edit the code including the 2 worksheet. Same format with the original worksheet. Thanks.
Please Login or Register to view this content.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks