问题
What I am trying to is that, I want to add multiple items into the clipboard then paste the second item when I press ctrl+q instead the first one. Here is my code but I'm getting the first one.
Sub Macro1()
'
' Macro1 Macro
'
' Keyboard Shortcut: Ctrl+q
'
Dim DataObj As New MSForms.DataObject
Dim S As String
On Error GoTo NotText
DataObj.GetFromClipboard
S = DataObj.GetText 'take the first one into S
T = DataObj.GetText 'take the second one into T
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
NotText:
'don't want anything to happen.
ActiveCell.Value = T 'paste the second one(doesn't work)
End Sub
来源:https://stackoverflow.com/questions/25807122/excel-vba-paste-the-second-item-from-clipboard