+ Reply to Thread
Results 1 to 5 of 5

Undo function to undo Visual Basic commands

Hybrid View

  1. #1
    Forum Contributor pierre08's Avatar
    Join Date
    02-16-2010
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    166

    Undo function to undo Visual Basic commands

    Hi guys,
    is there a function that can undo Visual Basic commands??
    After executing a macro is there a function that can undo the workbook (Other than saving the workbook before the execution of the macro)

    Thanks for your help
    Last edited by pierre08; 06-15-2010 at 05:00 AM.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Undo function to undo Visual Basic commands

    Running VBA any code clears the Undo stack therefore preventing anything being 'undone'. You can use Application.Undo immediately in a worksheet change event if someone has entered a value you don't want them to for example but that's about it.

    I've seen code that builds up a history of changes that then allows a custom undo routine to be used but never really tried it myself and don't think it's ever that perfect.

    I thought I'd read somewhere that things might have changed in Excel 2010 (don't quote me on that though as not seen it yet).

    Dom
    Last edited by Domski; 06-15-2010 at 04:49 AM.
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Undo function to undo Visual Basic commands

    They have made some changes to undo/redo in 2010 but doesn't look like that includes anything to do with code: http://blogs.msdn.com/b/excel/archiv...05/477660.aspx

    Not surprised really.

    Dom

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,983

    Re: Undo function to undo Visual Basic commands

    No - you have to write another macro that undoes everything you just did and then assign it using Application.OnUndo. See this J-Walk tip for example.
    Everyone who confuses correlation and causation ends up dead.

  5. #5
    Forum Contributor pierre08's Avatar
    Join Date
    02-16-2010
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    166

    Re: Undo function to undo Visual Basic commands

    Thank you so much i have found the right code, thanks you

+ 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