Function to copy A predetermined range

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I would like to create a function, wich can insert a range into a woorksheet,

CopyRange(sourceRange, destination)

But I don's know how, any help ?
 
Hi
One line will do it

Worksheets("mysheet1").Range("A1:B10").Copy
Destination:=Worksheets("mysheet2").Range("A1")

Or as a sub
Sub CopyIt(SourceRange as Range, DestinationRange as Range)
SourceRange.Copy Destination:=DestinationRange
End Sub

which you would use as

Set Range1 = Worksheets("mysheet1").Range("A1:B10")
Set Range2 = Worksheets("mysheet2").Range("A1")

CopyIt Range1, Range2

Make sure destinationRange is one cell though.
regards
Paul
 

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