Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
undoing a pivot table | Excel Programming | |||
Undoing formula | Excel Discussion (Misc queries) | |||
undoing the for next procedure | Excel Programming | |||
Undoing a macro | Excel Programming | |||
undoing a VB action | Excel Programming |