+ Reply to Thread
Results 1 to 4 of 4

Stop undo stack from clearing

  1. #1
    Registered User
    Join Date
    10-29-2009
    Location
    Houston, TX
    MS-Off Ver
    Excel 2003
    Posts
    1

    Stop undo stack from clearing

    As you may already know, MS Excel clears the undo stack upon running a macro or executing code.

    Does anyone know how to eliminate this or any work around?

    Please chime in.

    Thanks.

  2. #2
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: Stop undo stack from clearing

    The work around is obvious to save before you run the macro.

    This is what I picked up from the internet
    This is the code to set the Undo command:
    Application.OnUndo "Undo the ZeroRange macro", "undozero"
    Where undozero is the name of the macro to be run which un-does the original macro, and the other bit is the text to show the user.
    I haven't tried it. Have to investigate myself. It comes down to the fact that you can't undo a macro using normal Undo. What you can do is write a macro which undoes what the first one did and then use Application.OnUndo e.g.
    Last edited by rwgrietveld; 10-29-2009 at 05:27 PM.
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  3. #3
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile Re: Stop undo stack from clearing

    Good evening ohiggs

    ...and welcome to the forum!!
    Quote Originally Posted by ohiggs View Post
    As you may already know, MS Excel clears the undo stack upon running a macro or executing code.
    Does anyone know how to eliminate this or any work around?
    You cannot eliminate this - only work with it. You will need to write your own custom undo routine, but it's not exactly straightforward. There are a couple of articles by John Walkenbach here and here about the subject and how to get around it.

    There's also an article / tutorial here by Jan Karel Pieterse, along with a "one size fits all" type solution - the idea is you just copy his code into your application and it should do all the hard work for you.

    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Stop undo stack from clearing

    Running a macro does not intrinsically flush the undo stack; modifying a worksheet does.

    There is no simple way to get around it. If you're not faint of heart, see http://j-walk.com/ss/excel/tips/tip23.htm.
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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