Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building Undo Into an Excel VBA Macro

Tags:

undo

excel

vba

Excel macros do not seem to allow the use of "undo" after running them. Is there any way to bake undo functionality into a VBA macro in Excel?


1 Answers

Excel VBA has the Application.OnUndo function to handle this:

Public Sub DoSomething

    ... do stuff here

    Application.OnUndo "Undo something", "UnDoSomething"
End Sub

Public Sub UnDoSomething

    ... reverse the action here

End Sub
like image 96
e.James Avatar answered Sep 12 '25 09:09

e.James