How to keep the cliboard, after executing a VBA code

Viewed 29

Before executing a VBA code, I copy a text from Excel or any other source into my clipboard, and I would like to keep using the clipboard after executing the macro.

For example. I have this simple code (to clear the data in filtered list), and I would like to keep using the cliboard after running the code. However I'm getting a gibberish after pasting the data:

Sub Show_All_Data() 'Without keeping the cliboard
On Error Resume Next
ActiveSheet.ShowAllData
End Sub

Sub Show_All_Data() 'Keeping the cliboard after executing the code
On Error Resume Next
Dim DataObj As MSForms.DataObject
Set DataObj = New MSForms.DataObject
DataObj.GetFromClipboard
mystring = DataObj.GetText(1)
ActiveSheet.ShowAllData
With New MSForms.DataObject
.SetText mystring
.PutInClipboard
End With
Set objData = mystring
objData.SetText TempCopy2
objData.Text.PutInClipboard
End Sub

And this the text that I'm getting, after pasting the clipboard:

What am I missing here?

Thanks

0 Answers
Related