I have a macro that modifies the workbook it is executed in and I want that macro to save a copy of the workbook to a location (preferably specified by the user), revoke all changes to the workbook (so it’s in its original state again) and close the workbook.
Unfortunately I can’t find any input on the revoking and closing part… Saving a copy is pretty easy, but how to do the rest of those things?
I would agree with most of brettdj’s response (especially that you should save the file first). However, the BrowseForFolder function is unnecessary. Instead you can use the built-in Windows folder browser in post-2002 versions of Excel
The (False) on closing the workbook is short for SaveChanges:=False, and may remove the need to switch off alerts
Also, if you wish to make the changes to a different workbook to the one containing the code, you may need help using multiple Excel files. The main lesson would be that you can substitute ActiveWorkbook for ThisWorkbook, or define the workbook upon opening