P
Paige
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
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