+ Reply to Thread
Results 1 to 3 of 3

Bypassing "Undo"

  1. #1
    Registered User
    Join Date
    05-26-2010
    Location
    Kentucky
    MS-Off Ver
    Excel 2010
    Posts
    31

    Bypassing "Undo"

    I've got a macro that updates great quantities of cells iteravely. From the point of view of Excel, when I change one cell, I then go and change all those others. From time to time, I lose the "Undo" function entirely, which I believe is just Excel's way of throwing up its hands because it can't keep track of alllllllll the changes that automatically happen when I adjust one cell.

    So, in a flash of insight, I realized that I don't actually _need_ excel to keep track of all the individual changes. The code does that. So, my question becomes, "is there a way to turn off what feeds to the undo buffer?" Ideally, this would look like:

    1) I change a value, which is recorded in the undo buffer
    2) The macro turns off the buffer, and proceeds to adjust, say 200 entries on three tabs. At the end, the macro turns the buffer back on
    3) Now, the buffer only holds the original value of the single cell I changed in step 1, and I can move on, cell by cell.

    If I need to undo, I can, but the undo would only revert the values I altered on the control tab. The macro-altered cells will automatically recalculate and go back to what they were, and peace will reign throughout the land.

    Thanks!

  2. #2
    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: Bypassing "Undo"

    Excel isn't throwing up it's hands; as I said in your last thread, when a macro changes a cell (or most anything in the environment) the undo stack is flushed.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Valued Forum Contributor
    Join Date
    12-05-2011
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010 & 2013
    Posts
    308

    Re: Bypassing "Undo"

    A possible solution would be to copy the old cell value to the clipboard. That way, if you want to undo, you can simply paste the value back in. Not ideal, I know.

    Alternatively, keep track of your changes in a log file/hidden cell/global variable. Track the address and previous value. You will need to get the previous value on selecting the cell, prior to edit, as the change event only captures the address, not the previous value. Then, have an undo macro button that simply copies it back in.

+ 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