Frank Freese
asked on
VBA Undo
Folks,
I would like to create a module when called undo's a users action. I plan to use an ActiveX command button to call the module for that worksheet instead of selecting Undo from the Quick Access Toolbar. Creating the module, command button and calling the module is not an issue - just the module code.
I would like to create a module when called undo's a users action. I plan to use an ActiveX command button to call the module for that worksheet instead of selecting Undo from the Quick Access Toolbar. Creating the module, command button and calling the module is not an issue - just the module code.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
And it's a small point but for clarity IMO the indenting should be like this
Dim rng As Range
With ActiveSheet
For Each rng In .UsedRange
rng.Value = rng.Value
Next rng
End With
End Sub
ASKER
I just caught that coding error myself - now the first code works
I then tried the code you suggested to Undo and it failed at "Application.Undo"
Got a "Run time error 1004" with "Method 'Undo of object'_Application failed
I then tried the code you suggested to Undo and it failed at "Application.Undo"
Got a "Run time error 1004" with "Method 'Undo of object'_Application failed
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That did not work, but Martin, you gave me an idea I'd forgotten - the MsgBox. I've noticed how complicated the code can be to Undo. If you can come up with an easy way let me know and I'll re-post my question. But you have helped with the MsgBox option
ASKER
thanks - you were a big help
You're welcome and I'm glad I was able to help.
Marty - MVP 2009 to 2013
Marty - MVP 2009 to 2013
ASKER
Open in new window
The purpose of this is code is to delete all occurrences of a formula and replace the formula with the values from the results of the formula. I know I could copy the range I'm interested in and Paste with values.
The instructions state "The code changes all cells with formulas to cells containing values. Note that all formulas will be deleted. This is common need when copy tables where we need just the results of a calculation and no formulas or individual formatting."
This code is not working to begin with.