Excel VBA paste the second item from clipboard

隐身守侯 提交于 2020-02-05 10:06:37

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!