+ Reply to Thread
Results 1 to 3 of 3

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

  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

    I'm trying to make this application.onundo "undo" a range instead of a selection and I'm having trouble with it.

    For example, right now if I copy and paste one cell to another, I can undo the change via the native button.
    This undo function does not work if multiple cells are selected (range), since it's not currently saving the state of the previous copied range.

    If someone could point me in the right direction, that would be great!

    The code is below, thanks in advance for any help.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    01-13-2021
    Location
    Springfield, IL
    MS-Off Ver
    2016
    Posts
    3

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

    Sorry I didn't reply to the other thread. I'm new here and did not see any notifications (will need to check to see if there is an account setting).

    I think it might help to set some module level variables (PasteStart, PasteEnd). At the start of your paste procedure, call the selection_change procedure
    and have it check to see if a paste operation is coming. If so, store the values from the top left of the selected range through the end of the used range
    (but only for columns A:T) since you don't know how large the pasted range will be.

    I attached a workbook. Hopefully, it is in the right direction of what you are trying to do.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    02-20-2021
    Location
    BC, Canada
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    13

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

    Thank you very much for your assistance!

    With one minor adjustment I was able to have it do exactly as intended. I'm re-sending you the final revised code and have one task left!

    The workbook is attached - The remaining thing that I can't get to work is "Undo the paste of an entire row when the row is selected via the row number"
    The paste itself works with the minor change I made to your code.

    I think the change needs to be made here somewhere:

    Please Login or Register  to view this content.


    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.

    I appreciate the time you've put in to help me
    Attached Files Attached Files
    Last edited by MaddenJMF; 03-18-2021 at 10:28 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. 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
  2. Replies: 15
    Last Post: 10-21-2018, 01:54 AM
  3. 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
  4. 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
  5. Replies: 2
    Last Post: 05-06-2015, 02:44 AM
  6. Replies: 3
    Last Post: 12-22-2014, 02:24 PM
  7. Some copied cells are missing when pasted
    By paulkaye in forum Excel General
    Replies: 3
    Last Post: 07-01-2013, 03:38 AM

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