Excel VBA粘贴剪贴板中的第二个项目

时间:2014-09-12 11:21:00

标签: excel vba clipboard copy-paste

我想要的是,我想在剪贴板中添加多个项目,然后在按ctrl + q而不是第一个项目时粘贴第二个项目。这是我的代码,但我得到了第一个。

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

0 个答案:

没有答案