Hi folks,
I need to be able to undo whatever lands on the page whether it be from external or my example of copying/pasting a row as below.
I don't know how to define the pasted range - Currently it will only undo the cell that is selected when I complete the paste - Clarification will follow.
I have 2 pieces of my single undo procedure that I can't work out!
The workbook is attached
The remaining things that I can't get to work are:
> "Undo the paste of an entire row when the row is selected via the row number"
> "Undo the paste where the text copied to the clipboard externally spans multiple rows when pasted in excel - The "undo" only reverts the SELECTED CELL (i.e. Select A3 > Paste > External Copy pastes into A3 - A5 > Only A3 reverts as part of undo (since A4 and A5 were not selected)
I think the change needs to be made here somewhere:
Option Explicit
Public Type TYPE_Range
cells As Range
values As Variant
End Type
Public LastRangeChange As TYPE_Range
Public Sub UndoLastChange()
Dim newCell As TYPE_Range
If Not LastRangeChange.cells Is Nothing Then
Application.EnableEvents = False
LastRangeChange.cells.value = LastRangeChange.values
LastRangeChange = newCell
End If
Application.EnableEvents = True
End Sub
TRY IN ATTACHED WORKBOOK
1) Click on "Row 21" to select entire row (A:XFD)
2) CTRL+C to copy
3) Click on "Row 22" to select entire row (A:XFD)
4) CTRL+V to paste (shortcut assigned to macro)
Only_PasteValue_Or_Text
5) Attempt undo using native button - Fails
I can't work out what needs to change in the undo module as I've shared above
To clarify, the values highlighted in red is not an error, it's simply part of where my troubleshooting landed me as being a reason why I can't get what I need to work.
Bookmarks