arielon
03-11-2009, 08:30 AM
hi
I am writing a function that recieves to lists as range and I need to copy them into arrays. somehow I cant find a way to define the size of the arrays. because vb wont let me use application.count(list1) as a parameter.
I am attaching part of the function
Function attest(list1 As Range, list2 As Range)
avg1 = Application.Average(list1)
avg2 = Application.Average(list2)
n1 = Application.Count(list1)
n2 = Application.Count(list2)
Dim arr1(1 To n1) As Long
Dim arr2(1 To n2) As Long
For i = 1 To Application.Count(list1)
arr1(i) = 1
Next i
For i = 1 To Application.Count(list2)
arr2(i) = (list2(i) - avg2) ^ 2
Next i
end function
the error message is that the size of the aeeay must be constant. when trying to determing in Dynamicly I encounter the same problem on a loop that assigns the values
can anyone help?
I am writing a function that recieves to lists as range and I need to copy them into arrays. somehow I cant find a way to define the size of the arrays. because vb wont let me use application.count(list1) as a parameter.
I am attaching part of the function
Function attest(list1 As Range, list2 As Range)
avg1 = Application.Average(list1)
avg2 = Application.Average(list2)
n1 = Application.Count(list1)
n2 = Application.Count(list2)
Dim arr1(1 To n1) As Long
Dim arr2(1 To n2) As Long
For i = 1 To Application.Count(list1)
arr1(i) = 1
Next i
For i = 1 To Application.Count(list2)
arr2(i) = (list2(i) - avg2) ^ 2
Next i
end function
the error message is that the size of the aeeay must be constant. when trying to determing in Dynamicly I encounter the same problem on a loop that assigns the values
can anyone help?