Need Code for a Redo on Userforms

GWee

New Member
Joined
Nov 8, 2005
Messages
24
I like to put a "Redo" button on my userform. Does anybody know?
I'm using textboxes, checkboxes and options. After I click the ENTER I would like to Redo the entry steps..

Thanks! :-D
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Hello, GWee
Welcome to the Board !

what would you call "REDO"
sounds like "undoing" an "UNDO"
or do you mean "do something again which you just did" ?

please explain with some examples what you're trying to do

kin dregards,
Erik
 
Upvote 0
UNDO, REDO have some restrictions
you cannot undo or redo macroevents

Range("A1") = 1
cannot be redone or undone, unless you apply some tricks

can you provide an example of what you're trying to do ?

kind regards,
Erik
 
Upvote 0
Using UserForm to Undo and Redo

John Walkenbach (Author of Excel 2002 Power of Programming with VBA) created a Data Form replacement for Excel (addin tool for free) and did a redo and undo command button on his userform. How did he do the code?

Thanks!

GWee
 
Upvote 0
(sorry, missed your post, you could have send PM or email)You don't expect me to search the internet for JW's code, I hope ?
Just paste it here and we'll comment it...
OR
can you provide an example of what you're trying to do ?
just tell us what your problem is, so somebody can help

best regards,
Erik
 
Upvote 0
Sorry I don't know how much more info you need....

John Walkenbach did a Data Form Entry that has a Undo and Redo command just like Excel has on the toolbar. I know it can be done, I've seen it because I downloaded the addin.

I would like to know if anybody knew the code for this.

No example is necessary because it's a command for Undoing or Redoing of any value you just entered...

JW used a userform to make his version of a data form Entry using a undo and redo command.

Thanks for your comments!
 
Upvote 0
I've seen it because I downloaded the addin.
then provide the link please

let's be clear (again)
no operation using code (macro) can be "undone" unless the operation is logged some way
you tell us
a command for Undoing or Redoing of any value you just entered...
this can only be done when the value which has been replaced is stored somewhere
for multiple undo you can copy the sheet and hide it
when user selects "cancel all operations" the hidden sheet would replace the actual sheet ...


you tell us John WalkenBach has done this: FINE! but why do you expect others to search the internet if you already found something: just provide the link please!

little example (no userform, just normal module)
Code:
Option Explicit

Public OldValue As Variant
Public OldRange As Range

Sub replace_value()
OldValue = ActiveCell
Set OldRange = ActiveCell
ActiveCell.Value = Application.InputBox("Please enter something to add to " & ActiveCell.Address(0, 0), Title:="TITLE", Default:=ActiveCell)
End Sub

Sub undo()
OldRange.Value = OldValue
End Sub

Code:
I would like to know if anybody knew the code for this.
you've downloaded an add-in: isn't the code visible ?

kind regards,
Erik
 
Upvote 0
erik.van.geit said:
I've seen it because I downloaded the addin.
then provide the link please

let's be clear (again)
no operation using code (macro) can be "undone" unless the operation is logged some way
you tell us
a command for Undoing or Redoing of any value you just entered...
this can only be done when the value which has been replaced is stored somewhere
for multiple undo you can copy the sheet and hide it
when user selects "cancel all operations" the hidden sheet would replace the actual sheet ...


you tell us John WalkenBach has done this: FINE! but why do you expect others to search the internet if you already found something: just provide the link please!

little example (no userform, just normal module)
Code:
Option Explicit

Public OldValue As Variant
Public OldRange As Range

Sub replace_value()
OldValue = ActiveCell
Set OldRange = ActiveCell
ActiveCell.Value = Application.InputBox("Please enter something to add to " & ActiveCell.Address(0, 0), Title:="TITLE", Default:=ActiveCell)
End Sub

Sub undo()
OldRange.Value = OldValue
End Sub

Code:
I would like to know if anybody knew the code for this.
you've downloaded an add-in: isn't the code visible ?

kind regards,
Erik
http://www.j-walk.com/ss/dataform/index.htm

Eric, this is the file I downloaded and you will see the code is password protected. He's making you pay $20.00 for the CODE. However, the Data Form Entry can be dowloaded for free so you can see how he works in the "Undo/Redo method. Since I already did my version of a data form (lacking the Undo and Redo), I'm requesting if anybody out there knows the code to put this on ANY userform. I just want the code for this task not the whole data form code.

In his book (Page849, 2002 VBA Programming/Excel) I just found this and I will type out the question and his answer so I can get your feedback how to do this w/button on Userform:

CAN I LET THE USER UNDO MY MACRO?
Yes, but it's not something that can be done automatically. To enable the user to undo the effects of your macro, your VBA code module must keep track of what was changed by the macro and then be capable of restoring the original state if the user selects Edit-Undo.

To enable the Edit-Undo command, use the OnUndo method as the last action in your macro. This method enables you to specify text that will appear on the Undo menu item and also to specify a procedure to run if the user selects Edit-Undo. Here's an example:

Application.OnUndo "The Last Macro", "MyUndoMacro"

OK enough!
Thanks for your comments!
 
Upvote 0
CAN I LET THE USER UNDO MY MACRO?
Yes, but it's not something that can be done automatically. To enable the user to undo the effects of your macro, your VBA code module must keep track of what was changed by the macro
This is just what I've been telling you all the time.

He's making you pay $20.00 for the CODE.
don't know how many euro a dollar is, but if you want his code, just pay him

if you want help on a specific problem, which I've been asking from start, be welcome

some philisophy
to my sense people need to decide whether something has to be done or not: if they really hesitate, they can save their work, then do the changes and check: when not satisfied close without saves or saveas then reopen the original

I'm sure it's not so difficult to give some specific tips on building a userform with UNDO-REDO, but only when you tell what you would like to do specifically.

Erik
 
Upvote 0

Forum statistics

Threads
1,226,390
Messages
6,190,739
Members
453,615
Latest member
robbieb29

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