Type =Test2(5) in Excel after you put the code in the module. Why does this give me a Byref argument type mismatch error?
If at the beginning of Test2 I make one line to create my arrays:
Dim X1(5), X2(5) As Double , then it will work. But when I use b from the function argument list, I have to ReDim (because b is a variable, not a constant), which then causes an error.
Function Test1(a As Double) Test1 = a * 2 End Function Function Test2(b As Integer) Dim X1(), X2() As Double ReDim X1(b), X2(b) As Double Dim i As Integer For i = 0 To b X1(i) = i X2(i) = Test1(X1(i)) Next i Test2 = X2(1) End Function
user1125946
source share