Hi All,
is it possible to add some lines of code whatever macro the way it can also work as a sort of UNDO option and allow me to reverse back at the time just before I have launch it?
Thanks in advance
sasa
Hi All,
is it possible to add some lines of code whatever macro the way it can also work as a sort of UNDO option and allow me to reverse back at the time just before I have launch it?
Thanks in advance
sasa
Code wipes the UNDO stack, so you would somehow save all the changes yourself, them re-apply. Not trivial.
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
I see. But I think this way is very expensive, a lot of saved data....
Thank you again
sasa
Normally when you execute a macro its because the User believes that certain conditions have been met or that it is triggered by particular condition/s on the sheet.
However if you are unsure, that the conditions are right, yet you still feel you need to execute a macro... then you might try saving the file first. This way if the macro does something that then proves unsuitable, close the active book without saving changes.
Remember To Do the Following....
Use [Code].... [/Code] tags when posting code to the thread.
Mark your thread as Solved if satisfied by using the Thread Tools options.
If posting the same issue to another forum please show the link
You have 2 options here:
1. Create a worksheet and macro to track changes made to the workbook you will then be able to create a macro to reverse these changes
2. Create a macro that reverses the effect of the one you ran and call it MyUnDoMacro, then at the bottom of your original macro add this line
[VBA] Application.OnUndo "Undo My Macro", "MyUnDoMacro"[/VBA]the Undo My Macro is what the user would see and the latter part calls the macro, now after your macro has run you just click on the undo as you would normally and hey presto macro reversed!
Regards,
Simon
Please read this before cross posting!
In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
If I have seen further it is by standing on the shoulders of giants.
Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)
It is not possible copy the sheet of interest, make the changes, and then delete the copied sheet when one is sure of the changes or restore it if it is not so, maybe with a click on a icon on toolbar ?
sasa
Yes that would work if the changes are all about a single sheet. You could copy it, hide it, and just copy it back if required.
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber