copy selected cells to new workbook?

  • Thread starter Thread starter Chimanrao
  • Start date Start date
C

Chimanrao

hi

This is the workflow which I am trying to achieve:

a. The user selecets multiple cells using the mouse
b. I have a com based plugin which adds a button to excel
c. On cliking of button I copy the the selected cells to new workbook.

How do I get the the selected cells and copy them to the clipboard?

Regards
Chimanrao
 
Try

Selection.Copy

Note that many operations clear the clipboard, so you want to do
the Copy operation as close as possible to the Paste. Ideally,
the Copy and Paste operations will be on sequential lines of
code.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
I should have added that you can bypass the clipboard entirely by
specifying a destination in the Copy method. E.g.,

Selection.Copy
destination:=Workbooks("Book2.xls").Worksheets("Sheet1").Range("A1")


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
An unfortunate line wrap problem.

Chip's code goes on one line or use a continuation character so that it's still
one logical line:

Selection.Copy _
destination:=Workbooks("Book2.xls").Worksheets("Sheet1").Range("A1")
 
Do the COM interfaces accept the destination?
I am using VC++.

Regards
Chimanrao
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top