Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Should be straightforward answer...

Hello

If I write VBA code, run the procedure, and then want to
undo what I have just done, how do I do that?

For example, suppose I run the following procedure which
places the value 10 in cell A1 of the activeworksheet.

Sub XYZ ()
Range("A1").Value = 10
End Sub

How can I undo that?

I feel there ought to be an obvious way...but I can't
find it.

Thanks for any thoughts...

Alex
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Should be straightforward answer...

Hi
the Excel build-in functionality dows not work for macros. So you have
to program this on your own within your macro.

--
Regards
Frank Kabel
Frankfurt, Germany


Alex wrote:
Hello

If I write VBA code, run the procedure, and then want to
undo what I have just done, how do I do that?

For example, suppose I run the following procedure which
places the value 10 in cell A1 of the activeworksheet.

Sub XYZ ()
Range("A1").Value = 10
End Sub

How can I undo that?

I feel there ought to be an obvious way...but I can't
find it.

Thanks for any thoughts...

Alex


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Should be straightforward answer...

Should be, but not so easy.
http://tinyurl.com/4pdzk
From a posting by Chip Pearson

Running a VBA procedure clears Excel's undo buffer, effectively
disabling the Undo feature. The closest you can get is to create
a procedure that undoes your primary procedure, and use
Application.OnUndo to put that procedure in the undo buffer.
E.g.,

Sub AAAA()
Application.OnUndo "Undo This", "UndoProc"
End Sub

Sub UndoProc()
MsgBox "Undo code here"
End Sub
--
Cordially,
Chip Pearson


--
Don Guillett
SalesAid Software

"Alex" wrote in message
...
Hello

If I write VBA code, run the procedure, and then want to
undo what I have just done, how do I do that?

For example, suppose I run the following procedure which
places the value 10 in cell A1 of the activeworksheet.

Sub XYZ ()
Range("A1").Value = 10
End Sub

How can I undo that?

I feel there ought to be an obvious way...but I can't
find it.

Thanks for any thoughts...

Alex



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
What is the most straightforward (elegant) way to write this formu ewillig Excel Worksheet Functions 5 April 8th 10 05:15 PM
help with IF, if it is the answer.. Lost Will Excel Discussion (Misc queries) 1 November 19th 08 04:26 AM
Calculator Answer Doesn't Match Excel Answer GwenH Excel Discussion (Misc queries) 3 October 20th 08 10:17 AM
Same row different Answer. Steved Excel Worksheet Functions 2 July 22nd 05 01:34 AM
i cant get the exact answer e.g answer is 13.49% i got 13.00% zai Excel Discussion (Misc queries) 3 June 9th 05 01:00 PM


All times are GMT +1. The time now is 07:56 AM.

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

About Us

"It's about Microsoft Excel"