+ Reply to Thread
Results 1 to 3 of 3

Can't 'Undo' with VBA macro running

Hybrid View

  1. #1
    Registered User
    Join Date
    05-31-2005
    Location
    North Vancouver, B.C., Canada
    Posts
    53

    Can't 'Undo' with VBA macro running

    I have a spreadsheet (attached) with some VBA code running and if a mistake is made in the workbook, it will NOT allow me to 'UNDO' the mistake.

    I am hoping that someone can help me by telling me why this is happening and hopefully correct it...

    Thanks and best regards,

    leopardhawk
    Attached Files Attached Files

  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
    Any macro that changes the workbook flushes the UNDO buffer. It's a good reason not to use macros unless you really need them. Code can be written to support UNDO, but it's messy.

  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

    Good afternoon leopardhawk

    Unfortunately running a macro clears your undo stack, so you will lose multiple undo levels - there's no way around this. Many have tried and failed to pinpoint the memory address and all kinds of other complicated tricks.

    VBA allows you to hijack the undo command to reinstate one undo level to correct any mistakes. this technique is described here.

    However, Jan Karel Pieterse provides a routine here that is a generic undo handler - you might find this easier to implement.

    HTH

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

+ 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