FracinDean
Board Regular
- Joined
- Jul 11, 2011
- Messages
- 110
- Office Version
- 365
- Platform
- Windows
Good day Mr. Excel users,
Searching in the forum and online help have not helped me figure out how to use worksheet function Rank but using members of a VBA array as arguments. I made a simple example to work with. Here is what I have so far:
The values I'm trying to rank are virtual within VBA, they do not appear in cells in my spreadsheet.
The code above is generating a compile error, "Array Type Mismatch" on the argument "allVals()".
Assistance will be appreciated.
Searching in the forum and online help have not helped me figure out how to use worksheet function Rank but using members of a VBA array as arguments. I made a simple example to work with. Here is what I have so far:
Code:
[FONT=Verdana]Sub ranker()
Dim c As Variant, allVals() As Long
ReDim allVals(10)
For i = 1 To 10
allVals(i) = Application.WorksheetFunction.RandBetween(0, 100)
Next i
For Each c In allVals
Rank = Application.WorksheetFunction.Rank(c, allVals(), 0) ' Error on this row
Next c
End Sub
[/FONT]
The values I'm trying to rank are virtual within VBA, they do not appear in cells in my spreadsheet.
The code above is generating a compile error, "Array Type Mismatch" on the argument "allVals()".
Assistance will be appreciated.