Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default Codes for Undoing

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Codes for Undoing

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" wrote in message
...
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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default Codes for Undoing

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" wrote in message
...
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.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Codes for Undoing

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

"Varne" wrote in message
...
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.


  #5   Report Post  
Posted to microsoft.public.excel.programming
xlm xlm is offline
external usenet poster
 
Posts: 55
Default Codes for Undoing

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
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
undoing a pivot table JohnE Excel Programming 1 April 19th 08 12:04 PM
Undoing formula phil2006 Excel Discussion (Misc queries) 1 July 13th 06 11:33 AM
undoing the for next procedure mariasa[_14_] Excel Programming 4 March 13th 06 03:21 PM
Undoing a macro MissyLovesExcel Excel Programming 7 December 7th 05 04:12 PM
undoing a VB action RICH Excel Programming 2 November 14th 03 12:42 PM


All times are GMT +1. The time now is 09:55 PM.

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"