Forum Discussion
Vimal_Gaur
Jan 23, 2023Brass Contributor
VBA Undo
VBA - how to undo changes in xlsm file
1 Reply
- NikolinoDEPlatinum Contributor
Does the question refer to deleting a sheet, or to the sheet contents?
In general, macro actions cannot be undone.
You can also see this from the fact that after making changes to a sheet using a macro,
the "Undo" command or button is not active.
The VBA function "Undo" only undoes the last user input before running the macro.
But deleting the sheet cannot be undone.
When Worksheet_Change macros are running, the undo history is cleared. There's no avoiding that. You could undo the last input, like this with this example:
Sub NUndo() Application.Undo End Sub*but as I said...it depends on a lot.
As an additional tip for the future:to be on the safe side, you can have a backup copy created in "File -> Options -> Save".Then you always have a version before the last save.