Results 1 to 2 of 2

Application.OnUndo for Copy/Paste not working when > 1 Cells Copied/Pasted

Threaded View

MaddenJMF Application.OnUndo for... 04-16-2021, 12:27 PM
MaddenJMF Re: Application.OnUndo for... 04-27-2021, 02:36 AM
  1. #1
    Registered User
    Join Date
    02-20-2021
    Location
    BC, Canada
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    13

    Application.OnUndo for Copy/Paste not working when > 1 Cells Copied/Pasted

    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.
    Attached Files Attached Files
    Last edited by MaddenJMF; 04-16-2021 at 05:49 PM. Reason: Clarification/Attachment

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Application.OnUndo for Copy/Paste not working when > 1 Cells Copied/Pasted
    By MaddenJMF in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-18-2021, 10:25 PM
  2. hyperlink not working when copied and pasted
    By scouse13 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-11-2020, 06:56 PM
  3. Replies: 15
    Last Post: 10-21-2018, 01:54 AM
  4. Timer to automatically copy only if the previously copied one pasted
    By catchnanan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-14-2017, 12:56 PM
  5. Copy and paste cells when worksheet is copied
    By wellen72 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-12-2015, 12:16 PM
  6. Replies: 2
    Last Post: 05-06-2015, 02:44 AM
  7. Replies: 3
    Last Post: 12-22-2014, 02:24 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1