PC Review


Reply
Thread Tools Rate Thread

Codes for Undoing

 
 
Varne
Guest
Posts: n/a
 
      16th Dec 2008
Hi

Could somebody give me codes for undoing? It is urgent.

Sub Test ()

Cells(1,1).ClearContents
Application.Undo

End Sub

The above does not work.

Thanks.
 
Reply With Quote
 
 
 
 
Mike Fogleman
Guest
Posts: n/a
 
      16th Dec 2008
From Help for Undo...
This method undoes only the last action taken by the user before running the
macro, and it must be the first line in the macro. It cannot be used to undo
Visual Basic commands.

It can't Undo a VB command to ClearContents

You can assign the contents to a variable, ClearContents and then re-assign
the variable to the cell.



Mike F

"Varne" <(E-Mail Removed)> wrote in message
news:375814E8-5736-4BA8-AC9A-(E-Mail Removed)...
> Hi
>
> Could somebody give me codes for undoing? It is urgent.
>
> Sub Test ()
>
> Cells(1,1).ClearContents
> Application.Undo
>
> End Sub
>
> The above does not work.
>
> Thanks.



 
Reply With Quote
 
Varne
Guest
Posts: n/a
 
      16th Dec 2008
Thanks.

Could you please show me any method to do it - if any -?

M Varnendra

"Mike Fogleman" wrote:

> From Help for Undo...
> This method undoes only the last action taken by the user before running the
> macro, and it must be the first line in the macro. It cannot be used to undo
> Visual Basic commands.
>
> It can't Undo a VB command to ClearContents
>
> You can assign the contents to a variable, ClearContents and then re-assign
> the variable to the cell.
>
>
>
> Mike F
>
> "Varne" <(E-Mail Removed)> wrote in message
> news:375814E8-5736-4BA8-AC9A-(E-Mail Removed)...
> > Hi
> >
> > Could somebody give me codes for undoing? It is urgent.
> >
> > Sub Test ()
> >
> > Cells(1,1).ClearContents
> > Application.Undo
> >
> > End Sub
> >
> > The above does not work.
> >
> > Thanks.

>
>
>

 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      16th Dec 2008
You can't undo macros.

Public oldvalue
'put above as top line in module

Sub clearem()
oldvalue = Cells(1, 1)
Cells(1, 1).ClearContents
End Sub

Sub undoem()
Cells(1, 1) = oldvalue
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Varne" <(E-Mail Removed)> wrote in message
news:375814E8-5736-4BA8-AC9A-(E-Mail Removed)...
> Hi
>
> Could somebody give me codes for undoing? It is urgent.
>
> Sub Test ()
>
> Cells(1,1).ClearContents
> Application.Undo
>
> End Sub
>
> The above does not work.
>
> Thanks.


 
Reply With Quote
 
xlm
Guest
Posts: n/a
 
      16th Dec 2008
Hi Varne

However, you can have a macro to store the old value and have the changed
data restore back.

see this link http://j-walk.com/ss/excel/tips/tip23.htm

This can undo your subroutine only once. I would suggest that you save a
backup copy of your workbook / worksheets before running a macro.

HTH

--
If this posting was helpful, please click on the Yes button

Thank You

cheers,









"Varne" wrote:

> Hi
>
> Could somebody give me codes for undoing? It is urgent.
>
> Sub Test ()
>
> Cells(1,1).ClearContents
> Application.Undo
>
> End Sub
>
> The above does not work.
>
> Thanks.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
RegEx replace of html codes to ascii codes Greg -- Microsoft ASP .NET 4 9th Aug 2005 08:27 PM
Re: Query to look up a number of zip codes or area codes for bulkmail MGFoster Microsoft Access Queries 5 16th Apr 2005 04:38 AM
List of Codes and Display Names for Codes hoganc Microsoft Excel Discussion 1 12th Oct 2004 08:45 PM
List of Codes and Display Names for Codes hoganc Microsoft Excel Discussion 0 4th Oct 2004 04:25 PM
List of Codes and Display Names for Codes hoganc Microsoft Excel Discussion 1 4th Oct 2004 02:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:33 AM.