1 Answer - Sort by: Date | Rating
Yes, this is possible by using different techniques for example; you can write your module in such a way that can help in undoing the macros.
0
1
Add this code to any macro you want to be able to undo
Sum Example()
Call SaveUndo
Application.OnUndo "Undo_Macro", "Undo_Macro" (put this at end of macro)
End Sub
Add this to the declarations at the top of the same module:
Public workbooknumber As Integer
Public currentworkbook As String
Public newworkbook As String
Then add the following two subs to complete the job:
Sub SaveUndo()
Dim Number As String
If ActiveWorkbook.Path = "C:\TEMP" Then workbooknumber = workbooknumber + 1
If workbooknumber = 0 Then Number = "" Else Number = workbooknumber
currentworkbook = ActiveWorkbook.Name
newworkbook = Replace(currentworkbook, ".xls", "")
newworkbook = newworkbook + Number
newworkbook = newworkbook + ".xls"
SAVE:
ActiveWorkbook.SaveCopyAs "C:\TEMP\" + newworkbook
End Sub
Sub Undo_Macro()
Workbooks(currentworkbook).Close SaveChanges:=False
Workbooks.Open ("C:\TEMP\" + newworkbook)
MsgBox ("Make sure you save this file to the correct directory. " + newworkbook + " is currently saved in the temp directory")
End Sub
The above two macros temporarily save your file before running the desired macro. After running the original macro, select undo_macro on the undo button list and you will be reverted back to the saved version of the file.
Hope this helps!
Sum Example()
Call SaveUndo
Application.OnUndo "Undo_Macro", "Undo_Macro" (put this at end of macro)
End Sub
Add this to the declarations at the top of the same module:
Public workbooknumber As Integer
Public currentworkbook As String
Public newworkbook As String
Then add the following two subs to complete the job:
Sub SaveUndo()
Dim Number As String
If ActiveWorkbook.Path = "C:\TEMP" Then workbooknumber = workbooknumber + 1
If workbooknumber = 0 Then Number = "" Else Number = workbooknumber
currentworkbook = ActiveWorkbook.Name
newworkbook = Replace(currentworkbook, ".xls", "")
newworkbook = newworkbook + Number
newworkbook = newworkbook + ".xls"
SAVE:
ActiveWorkbook.SaveCopyAs "C:\TEMP\" + newworkbook
End Sub
Sub Undo_Macro()
Workbooks(currentworkbook).Close SaveChanges:=False
Workbooks.Open ("C:\TEMP\" + newworkbook)
MsgBox ("Make sure you save this file to the correct directory. " + newworkbook + " is currently saved in the temp directory")
End Sub
The above two macros temporarily save your file before running the desired macro. After running the original macro, select undo_macro on the undo button list and you will be reverted back to the saved version of the file.
Hope this helps!
- Anyone Know Any Cheats On New Super Mario Bros On Ds?
- How Do U Enter Cheat Codes On Madden Nfl 10?
- Can You Play Playstation 3 Network Online Without Wifi?
- What Are Some Cheat Codes For $100,000,000 On Meez.com?
- How To Put Digital Camera As A Webcam On Msn?
- I Cant Un Lock My Ipod Touch What Do I Do?
- What Website Has Free Nude Fakes Of Celebrities?
- How To Put Skype On Outlook Express?
- How Can I Find A Blank Page To Type On?
- How Do You Get The Azureflute?
- What Was The Yahoo Founders Motivation To Create A Search Engine?
- Which Should I Buy Ipod,xbox360,or Playstatoin3?
- How To Post Imikimi On Facebook?
- I Want A Website For A 11 Year Old Not Webkinz Moshimonsters Fantage Dizzywood And U Cant Chat You Can Only Use Safe Chat?
- How Do I Text On A House Phone?
- What Is Somebody Password And User Name For Club Penguin?
- How Can I Put My Name On My Profile?
- Which Is More Expensive Plasma Or Lcd?
- How Do I Change The Password For My Webcam?
- What Is The Difference Between The Mitsubishi WD-73797 1080p DLP HDTV And The Mitsubishi WD-73C9 1080p DLP HDTV?
- How Many Articles Are In A Magazine?
- When I Plug The Usb Cord To Upload Photos, It Will Not Work. Help?
- If You Go On Youtube On Your Phone And It Says Error Malformed Url How Do Fix It?
- How Can I Get My Camera's Usb Cord To Connect To Computer?
- What Should I Get For Our World Thats Under Ten Gems?

New Comment - Comments are editable for 5 min.