PDA

View Full Version : [SOLVED:] Array Indexing - Please help, at a loss for words...



mattreingold
05-29-2018, 07:55 AM
What I am trying to do is simple - I know that. I cannot figure out for the life of me why I am getting a subscript out of range error... At this stage I am simply trying to load a constant value (AreaReal) to an array (areaArr). I want every element in the array to be this constant value so I can then take the 'loadArr' and divide it by 'areaArr' in a looping manner. I have searched and searched and either diving 'loadArr' by 'AreaReal' or this approach im taking now to divide each arrays element by eachother would work... Any direction would be much much appreciated!!


Dim loadArr()
Dim areaArr()
Dim stressArr()


loadArr = WSR.Range("AY267:AY" & TotalRows).Value
maxVal = WorksheetFunction.Max(loadArr())
Area = WSR.[AQ267].Value
AreaReal = 1000000 * Area


For q = LBound(loadArr) To UBound(loadArr)
areaArr(q) = AreaReal
Next q


For v = LBound(loadArr) To UBound(loadArr)
stressArr(v) = loadArr(v, 1) / areaArr(q)
Next v

mattreingold
05-29-2018, 08:00 AM
And this becomes a trend, solving my own hour long problems seconds after postion... lol.

All I had to do was 'ReDim' both areaArr and stressArr to the lower and upper bound of 'loadArr'.

I guess the subscript out of bounds error comes from the fact that areaArr and stressArr were never sized... :yes:banghead:

snb
05-29-2018, 12:41 PM
Sub M_snb()
sm = [index(Ay267:AY300/AQ267*10^6,)]
End Sub

mattreingold
05-29-2018, 12:58 PM
Snb, you are so concise and professional, thank you!