PC Review


Reply
Thread Tools Rate Thread

copy from sheet 1 to sheet 2 values

 
 
ian bartlett
Guest
Posts: n/a
 
      28th Jun 2007
Hi:
My problem, on sheet 1 I have 6 defined named ranges
range1,range2 etc.
I would like to copy them to sheet 2 starting at row 2 what would be the
most efficient way to do this.

thanks Bart.


 
Reply With Quote
 
 
 
 
=?Utf-8?B?dmJhcHJv?=
Guest
Posts: n/a
 
      28th Jun 2007
you can use something like

Sub test()
Dim RangeNames As Variant
Dim RangeIndex As Long
Dim LastRow As Long
Const ShName1 = "Sheet1"
Const ShName2 = "Sheet2"

RangeNames = Array("Range1", "Range2", "Range3")

LastRow = 1
For RangeIndex = LBound(RangeNames) To UBound(RangeNames)
Worksheets(ShName1).Range(RangeNames(RangeIndex)).Copy _
Destination:=Worksheets(ShName2).Cells(LastRow + 1, 1)

LastRow = LastRow +
Worksheets(ShName1).Range(RangeNames(RangeIndex)).Rows.Count
Next RangeIndex

End Sub

"ian bartlett" wrote:

> Hi:
> My problem, on sheet 1 I have 6 defined named ranges
> range1,range2 etc.
> I would like to copy them to sheet 2 starting at row 2 what would be the
> most efficient way to do this.
>
> thanks Bart.
>
>
>

 
Reply With Quote
 
ian bartlett
Guest
Posts: n/a
 
      28th Jun 2007
Thanks vbapro

That looks like it should do the trick.
Bart

"vbapro" <(E-Mail Removed)> wrote in message
news:80877DC4-F1CD-4CE5-92E3-(E-Mail Removed)...
> you can use something like
>
> Sub test()
> Dim RangeNames As Variant
> Dim RangeIndex As Long
> Dim LastRow As Long
> Const ShName1 = "Sheet1"
> Const ShName2 = "Sheet2"
>
> RangeNames = Array("Range1", "Range2", "Range3")
>
> LastRow = 1
> For RangeIndex = LBound(RangeNames) To UBound(RangeNames)
> Worksheets(ShName1).Range(RangeNames(RangeIndex)).Copy _
> Destination:=Worksheets(ShName2).Cells(LastRow + 1, 1)
>
> LastRow = LastRow +
> Worksheets(ShName1).Range(RangeNames(RangeIndex)).Rows.Count
> Next RangeIndex
>
> End Sub
>
> "ian bartlett" wrote:
>
>> Hi:
>> My problem, on sheet 1 I have 6 defined named ranges
>> range1,range2 etc.
>> I would like to copy them to sheet 2 starting at row 2 what would be the
>> most efficient way to do this.
>>
>> thanks Bart.
>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Search for values in a sheet and copy found records one after theother in another sheet AndreasHermle Microsoft Excel Programming 12 17th Jun 2011 08:12 PM
copy values generated by conditional formula in one sheet to the other work sheet as values ramana Microsoft Excel Worksheet Functions 1 5th Oct 2005 01:04 PM
copy values generated by conditional formula in one sheet to the other work sheet as values bobby Microsoft Excel Misc 1 5th Oct 2005 12:18 PM
copy values generated by conditional formula in one sheet to the other work sheet as values bobby Microsoft Excel Discussion 1 5th Oct 2005 10:20 AM
how to find and copy values on sheet 2, based on a list on sheet 1 =?Utf-8?B?ZXZhbm1hY256?= Microsoft Excel Programming 4 7th Feb 2005 08:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:51 PM.