Copy items from Clipboard

JohnRyan

New Member
Joined
Jan 4, 2014
Messages
9
I have 2 items copied to the Clipboard in XL
I need a Macro to Paste item 1 to Sheet1, item 2 to Sheet2
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Hi Oldbrewer,

Thank you for your reply. I manually pasted item 1 to Sheet1 and item 2 to Sheet2 and recorded the Macro.

When I run the macro :-

Sub Macro1()

ActiveSheet.Paste
Sheets("Sheet2").Select
ActiveSheet.Paste

End Sub


It pastes item one into both sheets
 
Upvote 0
You would need to paste from the Office clipboard, not the Excel clipboard. That's much more complicated, and would require some Windows API.
 
Upvote 0
How did those "two items" get pasted into the clipboard.
What are they? Strings?

What does this return
Code:
Sub test()
    Dim myDO As New DataObject

    With myDO
        .GetFromClipboard
        MsgBox .GetText()
    End With
End Sub
 
Upvote 0
Hi, mikerickson

I copied them separately into the clipboard using Right Mouse Clicks.
I tried Strings first - first item = "a" and second item = "b".
Then I tried integers - first item = 1 & second item = 2.


Your macro above gave the following message when I tried to run it :-

Compile error:
User-defined type not identified
 
Upvote 0
Mike's code requires that you set a reference to Microsoft Forms Object Library. Ot you could use this:

Code:
Sub test()
    With CreateObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
        .GetFromClipboard
        MsgBox .GetText()
    End With
End Sub
 
Upvote 0
Dear SHG, when I run your code above it displays a Microsoft Excel Box showing the latest item from the clipboard, provided it’s not data from Excel

When I try to paste data from Excel I get the following Error message
Data Object GetText invalid FORMATETC structure
 
Upvote 0
Right; see post#4. You need to get data from the Office clipboard, not the Excel clipboard.
 
Upvote 0

Forum statistics

Threads
1,213,521
Messages
6,114,104
Members
448,548
Latest member
harryls

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top