JR_Chicago
New Member
- Joined
- Apr 20, 2010
- Messages
- 23
I have 10 one-dimensional arrays of numerical values, each of which contains 10 elements...
I have declared the arrays as Variants and have assigned ranges of cells to the arrays as follows:
array1 = Worksheets("Sheet1").Range("B2:K2").Value
array2 = Worksheets("Sheet1").Range("B3:K3").Value
etc etc...
I want to find the values for the first and last elements in these arrays but am having trouble writing the code to do so.
I read about the LBound and UBound functions but when I use those the value that is returned is "1" in both cases.
I've tried:
array1First = array1(1)
array1Last = array1(10)
Thinking that in an array with 10 elements, that such a convention would work but I just get an error message...
Also, I am trying to construct a one-dimensional array with 8 elements, each of which is a numerical value.
For this array, there is no range within the worksheet where the values are contained which I can assign to the array, rather, the array will contain the first & last elements in another array, as well as the mean, median, mode, etc of another array. I've written:
Dim statArray1(8) As Double
statArray1(1) = array1Mean
statArray1(2) = array1Median
statArray1(3) = array1Mode
statArray1(4) = array1First
statArray1(5) = array1Max
statArray1(6) = array1Min
statArray1(7) = array1Last
statArray1(8) = array1Range
In hopes of assigning array1Mean, array1Median, etc to the 1st, 2nd, etc elements in the array, however when I print statArray1 to my worksheet, zeros are populated where I'd hoped to see the stats I assigned to the array. I know the stats are being calculated properly so it must be the way I am assigning them to the array.
Any suggestions would be much appreciated!
Thanks a million!
I have declared the arrays as Variants and have assigned ranges of cells to the arrays as follows:
array1 = Worksheets("Sheet1").Range("B2:K2").Value
array2 = Worksheets("Sheet1").Range("B3:K3").Value
etc etc...
I want to find the values for the first and last elements in these arrays but am having trouble writing the code to do so.
I read about the LBound and UBound functions but when I use those the value that is returned is "1" in both cases.
I've tried:
array1First = array1(1)
array1Last = array1(10)
Thinking that in an array with 10 elements, that such a convention would work but I just get an error message...
Also, I am trying to construct a one-dimensional array with 8 elements, each of which is a numerical value.
For this array, there is no range within the worksheet where the values are contained which I can assign to the array, rather, the array will contain the first & last elements in another array, as well as the mean, median, mode, etc of another array. I've written:
Dim statArray1(8) As Double
statArray1(1) = array1Mean
statArray1(2) = array1Median
statArray1(3) = array1Mode
statArray1(4) = array1First
statArray1(5) = array1Max
statArray1(6) = array1Min
statArray1(7) = array1Last
statArray1(8) = array1Range
In hopes of assigning array1Mean, array1Median, etc to the 1st, 2nd, etc elements in the array, however when I print statArray1 to my worksheet, zeros are populated where I'd hoped to see the stats I assigned to the array. I know the stats are being calculated properly so it must be the way I am assigning them to the array.
Any suggestions would be much appreciated!
Thanks a million!
Last edited: