I am completely new to VBA. I need to write a program, which will generate an array of integer and will find an index of the minimal element. I got this error "Type mismatch: array or user-defined type expected." I looked into many similar questions, but couldn't figure out what is wrong.
Function random_integer(Min As Integer, Max As Integer)
random_integer = Int((Max - Min + 1) * Rnd + Min)
End Function
Function generate_array(Size As Integer)
Dim Arr(Size)
For i = 0 To UBound(Arr)
Arr(i) = random_integer(i - 10, i + 10)
Next
generate_array = Arr
End Function
Function find_index_of_min_elem(ByRef Arr() As Variant)
Dim Min As Integer
Min = Arr(0)
Dim MinIndex As Integer
MinIndex = 0
For i = 1 To UBound(Arr)
If Arr(i) < Min Then
Min = Arr(i)
MinIndex = i
End If
Next
find_index_of_min_elem = MinIndex
End Function
Sub task6()
A = generate_array(20)
IndexOfMinElemInA = find_index_of_min_elem(A)
MsgBox IndexOfMinElemInA
End Sub

I am completely new to VBA....Did you write this code?snake_caseand adoptPascalCasefor member names. In VBA the underscore has a special meaning; your functions can't be refactored into an interface named like that.