undo a macro

Julica

Active Member
Joined
Dec 17, 2002
Messages
267
Is there any way to set up a macro so that you can still use Undo after you have run it?
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Check this out and see if it is any help. It sounds like it'll be complicated if what you are doing is very detailed.
 
Upvote 0
I guess from playing [not tested] the main issues guys want to undo is critical like sheet delete, col row delete and clear range contence, this i have my dounbts as VBA is unconditional, hope im wrong


Fix

BACK UP often more the better!

Jack
 
Upvote 0
Hi, when mucking around with code I tend to take a copy of the file concerned rather than use the original file.

I then also save the workbook prior to running the code and if the outcome is not as I would expect I can always close it and select No to saving. This way I have kept my code but not done any damage.
 
Upvote 0
Hi Julica,

In general macros cannot be undone. If you want to protect yourself from the harm that running a macro inadvertantly can do, Jack's suggestion is a good one. In some cases it is possible to write an Undo macro that reverses what the previous macro did, but it has to be written specifically for this one Undo operation. And this is not always possible because some operations cannot be reversed (a good example of this is determining a password).

Damon
 
Upvote 0
I have macros set up and linked to toolbar buttons that I use on a regular basis in all sorts of different workbooks. Not enough disk space (or time) to be messing around with copies of every single file I use. I tried the undo macro that was in the link TommyGun posted [thanks! - btw] and with minimal adjustments, I can make it undo almost anything except formattng changes. I suppose those aren't critical since no data is actually lost, but it would be nice to be able to do that.

Teeth gnasher: Any previous operations are cleared from the undo list. How do you get it to ADD to the list instead of overwriting it?
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top