+ Reply to Thread
Results 1 to 7 of 7

Undo button from reset button

  1. #1
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,723

    Undo button from reset button

    Hi,
    I have a reset button in my worksheet and I added a UNDO button. Can you please create a code for me for the undo button. Thank you :o)
    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,723

    Re: Undo button from reset button

    Hi,
    Let me clarify. The reset button is to clear the A13-AE34 and AN13-AS34 cells. If for some reason I accidentally reset those cells, I want to be able to "undo" and bring those data back to the worksheet.

    Thanks.

  3. #3
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,907

    Re: Undo button from reset button

    You will have to store values some how, before you clear them. Be it array, dictionary, or workbook.

    Simplest method is to save a copy of workbook before you clear data, and copy them back in with undo.

    Ex:
    Please Login or Register  to view this content.
    Edit: Should have tested ErrHandle. Changed code to check if backup exist before executing rest of the code.
    Edit2: You may want to add code to delete backup after Undo is pressed.
    Last edited by CK76; 01-09-2019 at 04:12 PM.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  4. #4
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,723

    Re: Undo button from reset button

    Hi,
    Is there any simple code like my reset code.

    Like this:
    Sub Undo_Click()
    [A13:AE34,AN13:AS34].Value = ""
    End Sub

    I am not too familiar with the vba code so I thought it will be easier :o)

    thanks.

  5. #5
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,907

    Re: Undo button from reset button

    No. You can't undo action done by VBA. As whenever any code runs, it wipes undo cache.

    Alternate approach is to store values in memory and put it back to sheet when Undo is pressed. However, that will require just as much (or more) coding as above

  6. #6
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,723

    Re: Undo button from reset button

    Great! Thank you.

  7. #7
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,723

    Re: Undo button from reset button

    Hi,
    I added 2 more worksheet. I name the worksheet Page 1 and Page 2. Can you please edit the code including the 2 worksheet. Same format with the original worksheet. Thanks.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Create running stopwatch/timer with 1 button (start/stop). No reset button.
    By leeroy2612 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-26-2021, 12:59 AM
  2. VBA Button Undo option
    By WesP in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-21-2018, 09:00 AM
  3. Undo Button
    By keithy397 in forum Excel General
    Replies: 2
    Last Post: 09-16-2016, 10:19 AM
  4. [SOLVED] I need to create a reset button that will reset rows containing a specific value
    By odin78 in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 04-03-2016, 02:11 PM
  5. Undo last commad button
    By slmi1313 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-28-2009, 11:48 PM
  6. How to undo a button command?
    By jenniferkognan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-17-2008, 03:38 PM
  7. Undo button??
    By Bruise in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-18-2006, 08:15 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1