Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default UNDO in VBA code???

Okay, I wrote this really cool function, you see. It populates tons of blank
cells for the end-users, saving them hour upon hours of time. Everyone's
happy....except....

The function updates a bunch of data, but the "Undo" button is never
activated. So, if the want to undo the data changed by my way-cool function,
the only way for them to do it is to close the file without saving changes
and re-open it.

How do I get my code to activate the "Undo" button, so the changes can be
rolled back if needed?

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default UNDO in VBA code???

Joel,

When you run a procedure, the Undo buffer is cleared; previous
commands cannot be undone. You can create your own Undo
procedure, but when you go to Undo in the Excel UI, only this
procedure is available. Use Application.OnUndo to assign a
procedure to the Undo action. E.g.,

Public Sub AAA()
Application.OnUndo "Undo This", "UndoProc"
' your code here
End Sub

Sub UndoProc()
' code to undo
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Joel" wrote in message
...
Okay, I wrote this really cool function, you see. It populates
tons of blank
cells for the end-users, saving them hour upon hours of time.
Everyone's
happy....except....

The function updates a bunch of data, but the "Undo" button is
never
activated. So, if the want to undo the data changed by my
way-cool function,
the only way for them to do it is to close the file without
saving changes
and re-open it.

How do I get my code to activate the "Undo" button, so the
changes can be
rolled back if needed?

Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
ben ben is offline
external usenet poster
 
Posts: 232
Default UNDO in VBA code???

Simple answer, macros can not be undone, you'll have to write a roll back
feature into your macro.
ben

"Joel" wrote:

Okay, I wrote this really cool function, you see. It populates tons of blank
cells for the end-users, saving them hour upon hours of time. Everyone's
happy....except....

The function updates a bunch of data, but the "Undo" button is never
activated. So, if the want to undo the data changed by my way-cool function,
the only way for them to do it is to close the file without saving changes
and re-open it.

How do I get my code to activate the "Undo" button, so the changes can be
rolled back if needed?

Thanks!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default UNDO in VBA code???

Save the cells before the cool function kicks in, and provide a facility
that re-instates the data.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Joel" wrote in message
...
Okay, I wrote this really cool function, you see. It populates tons of

blank
cells for the end-users, saving them hour upon hours of time. Everyone's
happy....except....

The function updates a bunch of data, but the "Undo" button is never
activated. So, if the want to undo the data changed by my way-cool

function,
the only way for them to do it is to close the file without saving changes
and re-open it.

How do I get my code to activate the "Undo" button, so the changes can be
rolled back if needed?

Thanks!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default UNDO in VBA code???

John Walkenbach has some tips, too:
http://www.j-walk.com/ss/excel/tips/tip23.htm


Joel wrote:

Okay, I wrote this really cool function, you see. It populates tons of blank
cells for the end-users, saving them hour upon hours of time. Everyone's
happy....except....

The function updates a bunch of data, but the "Undo" button is never
activated. So, if the want to undo the data changed by my way-cool function,
the only way for them to do it is to close the file without saving changes
and re-open it.

How do I get my code to activate the "Undo" button, so the changes can be
rolled back if needed?

Thanks!


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA code to undo previous VBA action Preschool Mike Excel Discussion (Misc queries) 6 October 2nd 09 03:57 PM
UNDO - how many times can I UNDO? Jane Excel Worksheet Functions 2 May 19th 05 03:03 AM
Why is my undo function in Excel only can undo the last 1 or 2 ch. 1111111111111111111111111111111111111111 Excel Worksheet Functions 1 November 24th 04 11:13 AM
undo in code lrisser Excel Programming 2 August 11th 03 04:22 AM
Setting Font properties in Code clears Undo list Lorin Excel Programming 2 July 10th 03 09:49 PM


All times are GMT +1. The time now is 02:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"