E
ExcelMonkey
I have an array that I am trying to sort. I keep getting an this compile
error:
"Type Mismatch: array or user defined type expected "
on the line Call Sort(NumberOfRuns - 1, EBITDAArray). It highlights the
EBITDAArray.
Why is this? Thanks
Sub Main ()
Dim EBITDAArray as Variant
Dim X as Double
Dim NumberOfRuns as Double
For X = NumberOfRuns - 1
'Populate Array with code
Next
Call Sort(NumberOfRuns - 1, EBITDAArray)
End Sub
Sub Sort(n As Double, arr() As Variant)
Dim Temp As Double
Dim i As Long
Dim j As Long
For j = 2 To n
Temp = arr(j)
For i = j - 1 To 1 Step -1
If (arr(i) <= Temp) Then GoTo 10
arr(i + 1) = arr(i)
Next i
i = 0
10 arr(i + 1) = Temp
Next j
End Sub
error:
"Type Mismatch: array or user defined type expected "
on the line Call Sort(NumberOfRuns - 1, EBITDAArray). It highlights the
EBITDAArray.
Why is this? Thanks
Sub Main ()
Dim EBITDAArray as Variant
Dim X as Double
Dim NumberOfRuns as Double
For X = NumberOfRuns - 1
'Populate Array with code
Next
Call Sort(NumberOfRuns - 1, EBITDAArray)
End Sub
Sub Sort(n As Double, arr() As Variant)
Dim Temp As Double
Dim i As Long
Dim j As Long
For j = 2 To n
Temp = arr(j)
For i = j - 1 To 1 Step -1
If (arr(i) <= Temp) Then GoTo 10
arr(i + 1) = arr(i)
Next i
i = 0
10 arr(i + 1) = Temp
Next j
End Sub