Hi
I am trying to read data into an array for various reasons but I get the subscript out of range error.
I know the array is not dimensioned but the problem is that on each loop I do know know how many elements will be read. I assume that if I dim the array to 10 then the Ubound will become 10 and therefore I will have various zero entries.
I have tried to dimension the array with a variable "count" but that is not working either.
All help and learning appreciated.
I am trying to read data into an array for various reasons but I get the subscript out of range error.
I know the array is not dimensioned but the problem is that on each loop I do know know how many elements will be read. I assume that if I dim the array to 10 then the Ubound will become 10 and therefore I will have various zero entries.
I have tried to dimension the array with a variable "count" but that is not working either.
All help and learning appreciated.
Code:
count = 4
Dim arr() As Integer
'Dim arr(Count) As Integer - THIS DOESN'T WORK
arr(1) = 67
arr(2) = 21
arr(3) = 35
arr(4) = 28
For x = LBound(arr) To UBound(arr)
av = av + arr(x)
av = av / count
Next x
MsgBox "average = " & av