Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Undo Code Not Quite Working

I'm trying to modify John Walkenbach's code to 'undo' a VBA procedure that
deletes one or more rows. John's original code was to undo zeroes put into a
highlighted range. I can get the undo to work, except that once the rows are
deleted and the undo button is selected, it puts the deleted rows back over
existing data, versus 'inserting' them back into the correct place. I'm not
sure how to modify the following to allow for this. Can someone help?

' This saves the current values for undoing
ReDim OldSelection(Selection.Count)
Set OldWorkbook = ActiveWorkbook
Set OldSheet = ActiveSheet
i = 0
For Each cell In Selection
i = i + 1
OldSelection(i).Addr = cell.Address
OldSelection(i).Val = cell.Formula
Next cell

' This restores the saved information
For i = 1 To UBound(OldSelection)
Range(OldSelection(i).Addr).Formula = OldSelection(i).Val
Next i
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
Stop Undo Button from working in Excel 2007 after a Save Jugglertwo Excel Discussion (Misc queries) 1 October 15th 09 09:19 PM
UNDO in Office 2007 Excel not working. How fix? Panther Al Excel Discussion (Misc queries) 5 February 24th 08 04:32 PM
Why can cause undo and redo to stop working? GDB026 Excel Discussion (Misc queries) 2 December 18th 07 06:25 PM
UNDO in VBA code??? Joel Excel Programming 4 March 28th 05 07:14 PM
Undo not working with macro jbchrist[_2_] Excel Programming 4 August 9th 04 06:32 PM


All times are GMT +1. The time now is 12:18 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"