![]() |
Undoing a macro
Once a macro is run, can you "undo" it? Or, is there a second macro that will
reverse any previous macro just run? |
Undoing a macro
No, You'll have to take care of that yourself
-- Kind regards, Niek Otten "MissyLovesExcel" wrote in message ... Once a macro is run, can you "undo" it? Or, is there a second macro that will reverse any previous macro just run? |
Undoing a macro
Hi Missy,
See John Walkenbach's Undo notes at: http://www.j-walk.com/ss/excel/tips/tip23.htm --- Regards, Norman "MissyLovesExcel" wrote in message ... Once a macro is run, can you "undo" it? Or, is there a second macro that will reverse any previous macro just run? |
Undoing a macro
Nope. There is no Back button. Run is run and deleted is gone. You could
write something to reverse some actions but some actions are permanent. Be very careful what you write and prompt for any action that can not be undone. The undo button is also unavailable after the macro is run. You can use application.undo while a macro is running to undo the last action the last action performed. -- HTH... Jim Thomlinson "MissyLovesExcel" wrote: Once a macro is run, can you "undo" it? Or, is there a second macro that will reverse any previous macro just run? |
Undoing a macro
Missy, you can't undo a macro, but you can revert the file to the state
it was before the macro was run with this code: Sub RevertFile() wkname = ActiveWorkbook.path & "\" & ActiveWorkbook.Name ActiveWorkbook.Close Savechanges:=False Workbooks.Open FileName:=wkname End Sub HTH Greg |
Undoing a macro
That would seem to fall apart if the macro contained a Save command. And
really it's no different than saving the file just before you run your macro, then closing without saving changes if you don't like the results. "GregR" wrote in message ups.com... Missy, you can't undo a macro, but you can revert the file to the state it was before the macro was run with this code: Sub RevertFile() wkname = ActiveWorkbook.path & "\" & ActiveWorkbook.Name ActiveWorkbook.Close Savechanges:=False Workbooks.Open FileName:=wkname End Sub HTH Greg |
Undoing a macro
Ed, you are absolutely right, but if it doesn't contain a save command,
it is an alternative to recover the file. Greg |
Undoing a macro
Harald, I absolutely agree, and if any of the concerns expressed by
Harald or Ed pertain to your situation my solution will not work. I am just trying to express a solution to a simple macro that only acts on the active file and does not contain a save command. HTH Greg |
All times are GMT +1. The time now is 04:13 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com