ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Application.OnUndo Questions - Loses Prior Undo's and Runs 1x (https://www.excelbanter.com/excel-programming/275418-re-application-onundo-questions-loses-prior-undos-runs-1x.html)

Tom Ogilvy

Application.OnUndo Questions - Loses Prior Undo's and Runs 1x
 
the undo history is cleared by many macro actions. It is a pretty good
assumption to say you can't undo actions done by a macro. To the best of my
knowledge, using onundo replaces any built in undo capability - it doesn't
accumulate as history. If you want to undo a series of action, you would
have to make provision to record what was done, then have your macro access
that list and reverse it - perhaps querying the user for the actions to undo
or again, setting the onundo with a macro to do the next level of undos.

Basically the entire operation is your responsibility to code.

--
Regards,
Tom Ogilvy

"David Copp" wrote in message
. ca...
Hi,

Looking for comments + thoughts on the following.

When I programmatically assign Undo to my own procedure, I've noticed 2
things under 97 and 2K;
1. If I perform a series of standard Excel actions (e.g. add values to
cells), a list of the actions is available to undo (remove the values) via
the Undo icon in toolbar.
If however, I run "change_cells" once (shown below), all prior Undo

actions
to remove values are toast and left with "Undo Actions" only.
2. If change_cells is run multiple times, then only LAST "Undo Additions"

is
available. (i.e. what happened to prior "Undo Additions"? If run
"change_cells" 3x then hoping to see "Undo Additions" 3x under Undo icon

in
toolbar).
I'm more than happy to be responsible controlling how many times

undo_cells
runs but I would like it to be available more than once.
I also threw in the time (Application.OnUndo "Undo " & Time() ,
"undo_cells") and confirms that only most recent call to OnUndo is kept.
(ARG!)


Sub change_cells()
Cells(1, 1) = Cells(1, 1) + 1
Application.OnUndo "Undo Additions", "undo_cells"
End Sub


Sub undo_cells()
Cells(1, 1) = Cells(1, 1) - 1
Application.OnUndo "Undo Additions", "undo_cells"
End Sub


Thanks in advance,

Dave








All times are GMT +1. The time now is 05:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com