Copy Selection to new sheet

  • Thread starter Thread starter James
  • Start date Start date
J

James

Hi

How can I copy Multiple Selection selected by user to copy
to a new sheet using VBA. Excel 2002, win 2k
Please advise

Thanks a lot
James
 
Hi James,

You can't copy multiple selections in one go, so try something like

For Each area In Range("A1:A6,B1:B3,G2:J4,C16:D16")
area.Copy Destination:=Worksheets("Sheet1").Range(area.Address)
Next area

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Try this in a macro:

Sub CopyUserSelectedCells()
Dim mySelection as Range
Set mySelection = Selection 'Assigns the current user selection,
'even if it's multiple non-contiguous cells
For Each C In mySelection
'copy each cell here to wherever you want
Worksheets("Name of new sheet").Range("Cell to copy to") = C
Next
End Sub


TH
 
I think Bob meant this:

Dim area As Range
For Each area In Range("A1:A6,B1:B3,G2:J4,C16:D16").Areas
area.Copy Destination:=Worksheets("Sheet1").Range(area.Address)
Next area

Without the .areas, it'll do it cell by cell (which will work).

but judging by the variable name....
 

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