Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
PCH PCH is offline
external usenet poster
 
Posts: 7
Default Upload range into an array

I have a spreadsheet called, "Materials Codes and Prices.xls", with a sheet
named "Stock".
The sheet named Stock has Four columns containing:
Column A €“ Part numbers (integer)
Column B €“ Description (string)
Column C €“ Price (Double)
Column D €“ Weight (Double)

As new items are added to the list, the number of rows used is for ever
increasing.

How can I upload this ever increasing size of the range into an array into
another instance of Excel?

Thanks

Ashby

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Upload range into an array

Ashby,

If you can configure your data such that it will always be bounded by an
empty row and an empty column, you can use the CurrentRegion property to get
the full range of your data.

Sub AAA()
Dim V As Variant
Dim NumRows As Long
Dim NumCols As Long
Dim R As Long
Dim C As Long

V = Range("StartCell").CurrentRegion
NumRows = UBound(V, 1) - LBound(V, 1) + 1
NumCols = UBound(V, 2) - LBound(V, 2) + 1
For R = 1 To NumRows
For C = 1 To NumCols
Debug.Print CStr(V(R, C))
Next C
Next R
End Sub

Another way is to use the End property to go from the last row in the sheet
(Rows.Count = 64K in most versions of Excel) upward to the last used cell in
a column, such as "D".

Sub BBB()
Dim V As Variant
Dim LastRow As Long
Dim LastCell As Range
Dim Rng As Range

Const C_FIRST_ROW = 1 '<<< CHANGE AS NEEDED
LastRow = Cells(Rows.Count, "D").End(xlUp).Row
Set Rng = Range(Cells(1, "A"), Cells(LastRow, "D"))
V = Rng
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email on the web site)

"PCH" wrote in message
...
I have a spreadsheet called, "Materials Codes and Prices.xls", with a sheet
named "Stock".
The sheet named Stock has Four columns containing:
Column A €“ Part numbers (integer)
Column B €“ Description (string)
Column C €“ Price (Double)
Column D €“ Weight (Double)

As new items are added to the list, the number of rows used is for ever
increasing.

How can I upload this ever increasing size of the range into an array into
another instance of Excel?

Thanks

Ashby


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
how to upload exl Bob I Excel Discussion (Misc queries) 0 February 10th 09 02:10 PM
Upload worksheer? deepika :excel help[_2_] Excel Discussion (Misc queries) 1 February 13th 08 12:23 PM
copy one array formula to an array range guedj54 Excel Programming 2 October 29th 06 07:38 PM
FTP Upload Layne Excel Programming 1 July 11th 06 05:08 PM
Tricky array formula issue - Using array formula on one cell, then autofilling down a range aspenbordr Excel Programming 0 July 27th 05 03:59 PM


All times are GMT +1. The time now is 02:33 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"