cgcamal
Active Member
- Joined
- May 2, 2007
- Messages
- 472
Hi guys,
I'm trying to use Undo and Redo within a procedure but only works the Undo
and OnUndo nor Repeat seem to work.
I'm trying to do this with the below code:
1- Delete a value in any cell, let say A1 (this is the user action);
2- Run step by step the macro;
3- When Undo line is executed (like Ctrl+Z), Value in A1 appears (as before of step 1 happens);
4- But when OnUndo is executed, nothing happens. The expected result is to go back to step 1 (user action),
when the value was deleted and should disappear again like doing a Ctrl+Y.
I don't know if it is possible or I'm only doing it wrong.
Maybe somebody can help me.
Many thanks in advance.
Regards
I'm trying to use Undo and Redo within a procedure but only works the Undo
and OnUndo nor Repeat seem to work.
I'm trying to do this with the below code:
1- Delete a value in any cell, let say A1 (this is the user action);
2- Run step by step the macro;
3- When Undo line is executed (like Ctrl+Z), Value in A1 appears (as before of step 1 happens);
4- But when OnUndo is executed, nothing happens. The expected result is to go back to step 1 (user action),
when the value was deleted and should disappear again like doing a Ctrl+Y.
Code:
Sub MyMacro()
Application.Undo [COLOR=Green]'To return before last user action.[/COLOR]
Application.OnUndo "Undo VB Procedure", "Book1.xlsm!MyMacro" [COLOR=Green]'Expected to return to state of the last action generated by user.[/COLOR]
Range("A1").Select
End Sub
I don't know if it is possible or I'm only doing it wrong.
Maybe somebody can help me.
Many thanks in advance.
Regards