ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Function to copy A predetermined range (https://www.excelbanter.com/excel-programming/390122-function-copy-predetermined-range.html)

firsttimer

Function to copy A predetermined range
 
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 ?

[email protected]

Function to copy A predetermined range
 
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

On May 25, 10:31 am, firsttimer
wrote:
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 ?





All times are GMT +1. The time now is 07:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com