Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Read range to array

For a single column Range
v = Application.Transpose(Range("G1:G10").Value)

v is a 1d array.

If the range were Horizonal (single row range), then you would need

v =Application.Transpose(Application.Transpose(Range ("A1:M1").Value))

--
Regards,
Tom Ogilvy

"John Keith" wrote:


Dim vaFCR As Variant
vaFCR = ThisWorkbook.Sheets("Counterparty").Range("FactorC orrRange").Value

This code will load your FactorCorrRange into a 2d array.
Use UBound(vaFCR,1) and UBound(vaFCR,2) to get the upper end points for each
of the dimensions. Both dimensions will begin at 1, not 0 (so be careful,
since this is different than the norm when dimensioning arrays, depending on
the "option base #" statement)

If anyone can point to a good way to make this a 1d array (other than making
a single cell reference and then using .offset to load each cell individually
to the array element in a loop)... That is what I was looking for when I
loaded the newsgroup this morning.


--
Regards,
John


"Arne Hegefors" wrote:

Hi! I have a range. I want to loop through the range and place the values
from the cells into an array. However i have some trouble with the code. I
write:

Set rngCorr = ThisWorkbook.Sheets("Counterparty").Range("FactorC orrRange")
NoR = rngCorr.Rows.Count
ReDim dblCorrArray(NoR)
'here are the different correlations for the factos set
For i = 0 To NoR
dblCorrArray(i) = Range("FactorCorrRange").Offset(i, 0).Value
Next

I ger error 13 incompatible types. How shall i write the code? pls help!

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
Read through Range and copy Cell data to Array missleigh[_2_] Excel Programming 1 April 13th 06 12:47 PM
Read through Range and copy Cell data to Array missleigh[_2_] Excel Programming 1 April 13th 06 12:00 AM
How do i read Selection.Shapes.Range(Array(i)? Harry Excel Programming 2 September 6th 05 03:46 PM
Read a range to an array Microsoft Forum Excel Programming 4 January 23rd 05 05:23 PM
Read Range Data into Array Stratuser Excel Programming 1 April 26th 04 06:46 PM


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