Is there code to set up an "undo" button for Macro functions? Excel's undo button does not apply after running macros. Or at least, I don't know how to apply it.
There is a macro undo provision within Excel VBA, but not a particularly useful one without a lot of extra work:
application.onundo "Undo Cap Macro","UndoCapMacro"
will set the text of the edit-undo menu item to "Undo Cap Macro", and will run the sub "UndoCapMacro" when the menu item is chosen. However, it is still up to the programmer to actually implement the Undo. One option might be, as Dale suggested, to save a copy of the workbook, and retrieve it when the undo macro is called. In certain other cases, where the action of a macro is limited to a particular part of a workbook, it may make sense to copy just that part of the workbook to a temporary location (on a worksheet inside personal.xls or inside your add-in), and restore from that location. Rob
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.