Following is my function :
Function FindMin(MinArray() As Integer) As Integer()
Dim Min As Integer
Dim Index As Integer
Dim ReturnArray(2) As Integer
Dim i As Integer
Min = MinArray(0)
Index = 1
'MsgBox UBound(MinArray, 1) - 1
For i = 1 To UBound(MinArray, 1) - 1
If MinArray(i) < Min Then
Min = MinArray(i)
Index = i + 1
End If
Next i
ReturnArray(0) = Min
ReturnArray(1) = Index
'MsgBox ReturnArray(0)
FindMin = ReturnArray()
End Function
Here's the code that assigns it to a Variant
Dim IndexMin As Variant
IndexMin = FindMin(MinArray)
Min = IndexMin(0)
Index = IndexMin(1)
Values are assigned while debugging the code but it get an "Object variable or With block Variable not set Runtime Error.
Any suggestions