Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ray Ray is offline
external usenet poster
 
Posts: 267
Default right code, wrong range

Hello -

I'm using the following code to 'consolidate' info from multiple
sheets into a Master sheet. It works great, except that I'm only
getting the first two rows from each sheet. I've tried to modify the
code, but keep getting tripped up by xlLeft, xlUp, etc.

How should the code be modified to pull in the full used range on each
sheet?

Sub AABB()
Dim i As Long
Dim sh As Worksheet
Dim rng As Range
vArr = Array(......)
For i = LBound(vArr) To UBound(vArr)
Set sh = Worksheets(vArr(i))
Set rng = sh.Range(sh.Cells(2, 1), sh.Cells(2, 50).End(xlUp))
rng.Copy Destination:=Worksheets("Master") _
.Cells(Rows.Count, 1).End(xlUp)(2)
Next
End Sub

TIA, Ray

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default right code, wrong range

sh.Cells(2, 50).End(xlUp))

2 rows and 50 cols? You probably meant to switch these.


--
Jim
"Ray" wrote in message
oups.com...
| Hello -
|
| I'm using the following code to 'consolidate' info from multiple
| sheets into a Master sheet. It works great, except that I'm only
| getting the first two rows from each sheet. I've tried to modify the
| code, but keep getting tripped up by xlLeft, xlUp, etc.
|
| How should the code be modified to pull in the full used range on each
| sheet?
|
| Sub AABB()
| Dim i As Long
| Dim sh As Worksheet
| Dim rng As Range
| vArr = Array(......)
| For i = LBound(vArr) To UBound(vArr)
| Set sh = Worksheets(vArr(i))
| Set rng = sh.Range(sh.Cells(2, 1), sh.Cells(2, 50).End(xlUp))
| rng.Copy Destination:=Worksheets("Master") _
| .Cells(Rows.Count, 1).End(xlUp)(2)
| Next
| End Sub
|
| TIA, Ray
|


  #3   Report Post  
Posted to microsoft.public.excel.programming
Ray Ray is offline
external usenet poster
 
Posts: 267
Default right code, wrong range

On Mar 22, 9:58 am, "Jim Rech" wrote:
sh.Cells(2, 50).End(xlUp))


2 rows and 50 cols? You probably meant to switch these.

--
Jim"Ray" wrote in message

oups.com...
| Hello -
|
| I'm using the following code to 'consolidate' info from multiple
| sheets into a Master sheet. It works great, except that I'm only
| getting the first two rows from each sheet. I've tried to modify the
| code, but keep getting tripped up by xlLeft, xlUp, etc.
|
| How should the code be modified to pull in the full used range on each
| sheet?
|
| Sub AABB()
| Dim i As Long
| Dim sh As Worksheet
| Dim rng As Range
| vArr = Array(......)
| For i = LBound(vArr) To UBound(vArr)
| Set sh = Worksheets(vArr(i))
| Set rng = sh.Range(sh.Cells(2, 1), sh.Cells(2, 50).End(xlUp))
| rng.Copy Destination:=Worksheets("Master") _
| .Cells(Rows.Count, 1).End(xlUp)(2)
| Next
| End Sub
|
| TIA, Ray
|


Hi Jim -

Thanks for the response ... I'd actually 'recalled' my post, b/c I
figured out the answer myself! Yahoo!

I replaced
Set rng = sh.Range(sh.Cells(2, 1), sh.Cells(2, 50).End(xlUp))
With
Set rng = sh.UsedRange

so simple, yet so much frustration.... ;)

//ray

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
Is there something wrong with my code? Corey Excel Programming 5 February 19th 07 02:29 PM
What is wrong with this code to name a worksheet range Barb Reinhardt Excel Programming 4 November 2nd 06 08:38 PM
What's wrong with this code? PhilipsBernard Excel Programming 4 October 20th 05 07:30 AM
What's wrong with this code, please? Jim Berglund Excel Programming 1 August 3rd 04 09:41 PM
What's wrong w/my code? nrage21[_54_] Excel Programming 5 July 28th 04 03:50 PM


All times are GMT +1. The time now is 06:18 AM.

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

About Us

"It's about Microsoft Excel"