Search code examples
excelvbasendkeys

How to copy without losing information?


I am trying to copy a text from a range, but if someone press "ESC" or anything else, this information is lost.

I copy with this macro:

Sub Copiar_Reposta()

With Application
    .ScreenUpdating = False
End With

Planilha1.Select
Range("A45").Select
Application.CutCopyMode = False
Application.Wait (Now() + TimeValue("00:00:01"))
Application.SendKeys "{F2}", True
Application.SendKeys "+{HOME}", True
Application.SendKeys "^C", True
Application.SendKeys "{ESC}", True

Planilha3.Select

With Application
    .ScreenUpdating = True
End With

End Sub

Immediately the "NUM LOCK" turns off, and after trying to fix it, this macro stopped working as well.

Is there a way to copy the information from a cell without losing it after? Or, is there a way to fix my macro that stopped working suddenly.

Copy like this: Copying with "F2" and "CTRL + C"


Solution

  • Just to mark the question as answered, I solved the problem with the help from @Marcucciboy2, using this link Text To Clipboard in VBA Windows 10 Issue and this link Excel VBA code to copy a specific string to clipboard to copy information to my clipboard, when I searched the problem is a bug that occurs when "File Explorer" is open, I closed and it worked. But I'm not using this function anymore.