Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Copying named ranges from one sheet to another

Does anyone know how to achieve the following (as my do loop contstructions
are taking quite a while to execute and this would be far faster I am sure).

Column A contains dates which expand by one each day (funnily
enough). Basically I want to copy the dates from one sheet to another as
fast as possible, and then copy a column of numbers into the adjacent column
(I wnat to copy one column over each time so offset will probably do me when
I
get the syntax).

My idea is to define the column of dates as a named range
and then just say "the same range on sheet B is to equal the named range on
sheet A"
the idea being that just picking up the dates as a block and plonking them
in the destination sheet is likely to be quicker than assigning the values
one at a time as i do now using a do loop construction.

Would appreciate any pointers, kind regards, Mark


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Copying named ranges from one sheet to another

Hi,


Try something like this which copies from SheetA To SheetB without using
named ranges. Change ranges as needed

Sub CopyRng()

Dim lastrow As Long, InRng As Range, OutRng As Range

lastrow = Worksheets("SheetA").Cells(Rows.Count, "A").End(xlUp).Row

Set InRng = Range("A2:A" & lastrow) ' Input dates starting in A2

Set OutRng = Worksheets("SheetB").Range("a2") ' <== Change as required

InRng.Copy OutRng

End Sub

HTH

"Mark Stephens" wrote:

Does anyone know how to achieve the following (as my do loop contstructions
are taking quite a while to execute and this would be far faster I am sure).

Column A contains dates which expand by one each day (funnily
enough). Basically I want to copy the dates from one sheet to another as
fast as possible, and then copy a column of numbers into the adjacent column
(I wnat to copy one column over each time so offset will probably do me when
I
get the syntax).

My idea is to define the column of dates as a named range
and then just say "the same range on sheet B is to equal the named range on
sheet A"
the idea being that just picking up the dates as a block and plonking them
in the destination sheet is likely to be quicker than assigning the values
one at a time as i do now using a do loop construction.

Would appreciate any pointers, kind regards, Mark



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Copying named ranges from one sheet to another

Better ....

Sub CopyRng()

Dim lastrow As Long, InRng As Range, OutRng As Range

Set OutRng = Worksheets("Sheet2").Range("a2") ' <== Change as required

With Worksheets("Sheet1")
lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
Set InRng = .Range("a2:A" & lastrow)
End With

InRng.Copy OutRng

End Sub


"Toppers" wrote:

Hi,


Try something like this which copies from SheetA To SheetB without using
named ranges. Change ranges as needed

Sub CopyRng()

Dim lastrow As Long, InRng As Range, OutRng As Range

lastrow = Worksheets("SheetA").Cells(Rows.Count, "A").End(xlUp).Row

Set InRng = Range("A2:A" & lastrow) ' Input dates starting in A2

Set OutRng = Worksheets("SheetB").Range("a2") ' <== Change as required

InRng.Copy OutRng

End Sub

HTH

"Mark Stephens" wrote:

Does anyone know how to achieve the following (as my do loop contstructions
are taking quite a while to execute and this would be far faster I am sure).

Column A contains dates which expand by one each day (funnily
enough). Basically I want to copy the dates from one sheet to another as
fast as possible, and then copy a column of numbers into the adjacent column
(I wnat to copy one column over each time so offset will probably do me when
I
get the syntax).

My idea is to define the column of dates as a named range
and then just say "the same range on sheet B is to equal the named range on
sheet A"
the idea being that just picking up the dates as a block and plonking them
in the destination sheet is likely to be quicker than assigning the values
one at a time as i do now using a do loop construction.

Would appreciate any pointers, kind regards, Mark



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Copying named ranges from one sheet to another

Thabks for that Toppers it looks much more elegant than what I have I will
give it a try

Kind regards, Mark


"Toppers" wrote in message
...
Better ....

Sub CopyRng()

Dim lastrow As Long, InRng As Range, OutRng As Range

Set OutRng = Worksheets("Sheet2").Range("a2") ' <== Change as required

With Worksheets("Sheet1")
lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
Set InRng = .Range("a2:A" & lastrow)
End With

InRng.Copy OutRng

End Sub


"Toppers" wrote:

Hi,


Try something like this which copies from SheetA To SheetB without using
named ranges. Change ranges as needed

Sub CopyRng()

Dim lastrow As Long, InRng As Range, OutRng As Range

lastrow = Worksheets("SheetA").Cells(Rows.Count, "A").End(xlUp).Row

Set InRng = Range("A2:A" & lastrow) ' Input dates starting in A2

Set OutRng = Worksheets("SheetB").Range("a2") ' <== Change as required

InRng.Copy OutRng

End Sub

HTH

"Mark Stephens" wrote:

Does anyone know how to achieve the following (as my do loop
contstructions
are taking quite a while to execute and this would be far faster I am
sure).

Column A contains dates which expand by one each day (funnily
enough). Basically I want to copy the dates from one sheet to another
as
fast as possible, and then copy a column of numbers into the adjacent
column
(I wnat to copy one column over each time so offset will probably do me
when
I
get the syntax).

My idea is to define the column of dates as a named range
and then just say "the same range on sheet B is to equal the named
range on
sheet A"
the idea being that just picking up the dates as a block and plonking
them
in the destination sheet is likely to be quicker than assigning the
values
one at a time as i do now using a do loop construction.

Would appreciate any pointers, kind regards, Mark





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying Named Ranges in Chart Series Revolvr Charts and Charting in Excel 1 March 18th 10 12:21 PM
Copying Worksheets which contain Named Ranges Terry Bennett Excel Worksheet Functions 0 June 25th 09 05:04 PM
Stop named ranges from copying into other workbooks Mike Excel Worksheet Functions 1 April 2nd 08 04:23 PM
Copying Named Ranges Tom Perlman Excel Discussion (Misc queries) 4 December 14th 06 07:34 PM
named ranges and copying sheets to another workbook helpwithXL Excel Programming 1 May 17th 05 04:57 PM


All times are GMT +1. The time now is 04:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"