J
jasonsweeney
I have a VBA array of large numbers. I need to rank the items withi
the array and drop them (in order) into a textbox. For example:
Input: Array(27, 43, 51, 14, 33)
Output in textbox should be: 2, 4, 5, 1, 3 (delimited here wit
commas for informational purposes only. Actual output would b
"24513")
I would hope this would be simple in VBA, but looking at the post
regarding ranking and sorting arrays, it looks more difficult than
thought. And no, I don't want to put the data onto the worksheet an
rank it there. VBA code only please.
Here is the code I tried which does not work:
________________________________________
Private Sub CommandButton1_Click()
Myarray1 = Array(27, 43, 51, 14, 33)
For i = 1 To UBound(Myarray1)
Rank_num = Application.WorksheetFunction.Rank(Myarray1(i)
Myarray1, 0)
UserForm1.TextBox1.Value = UserForm1.TextBox1.Value & Rank_num
Next
End Sub
________________________________________
Suggestions appreciated
the array and drop them (in order) into a textbox. For example:
Input: Array(27, 43, 51, 14, 33)
Output in textbox should be: 2, 4, 5, 1, 3 (delimited here wit
commas for informational purposes only. Actual output would b
"24513")
I would hope this would be simple in VBA, but looking at the post
regarding ranking and sorting arrays, it looks more difficult than
thought. And no, I don't want to put the data onto the worksheet an
rank it there. VBA code only please.
Here is the code I tried which does not work:
________________________________________
Private Sub CommandButton1_Click()
Myarray1 = Array(27, 43, 51, 14, 33)
For i = 1 To UBound(Myarray1)
Rank_num = Application.WorksheetFunction.Rank(Myarray1(i)
Myarray1, 0)
UserForm1.TextBox1.Value = UserForm1.TextBox1.Value & Rank_num
Next
End Sub
________________________________________
Suggestions appreciated