What would I have to add to this VBA Code to keep Undo Button working after it runs?

Viewed 244

I was looking for VBA code so that any time I copy and paste text from anywhere into Excel, it will match the destination formatting. I found 2 different codes to do it:

Sub PasteWithDestinationFormatting()
ActiveCell.PasteSpecial (xlPasteAll)
End Sub

and

Sub PasteWithDestinationFormatting()
ActiveSheet.PasteSpecial Format:="Unicode Text", Link:=False, DisplayAsIcon:=False
End Sub

Both of them work but the problem is that they both disable the use of the "Undo" button, and the "Ctrl + Z" shortcut. I'm trying to figure out why that is and what I can do to fix it.

Thank you!

1 Answers

VBA destroys Excel's undo feature. You could implement your own undo via VBA, though that would be quite complex.

Related