Application.Volatile Dim DataArray As Object, temp As Object, n, topname As String Set DataArray = CreateObject("System.Collections.ArrayList") Set temp = CreateObject("System.Collections.ArrayList")
For i = 1 To 21 If Sheets("sheet1").Cells(r, i + 5) <> "" Then temp.Add Sheets("sheet1").Cells(r, i + 5).Value End If Next i
temp.Sort: temp.Reverse
For Each n In temp If Not DataArray.contains(n) Then DataArray.Add (n) Next
If top > DataArray.Count Then gettop = "" Exit Function End If
For i = 1 To 21 If Sheets("sheet1").Cells(r, i + 5).Value = DataArray(top - 1) Then topname = topname & Sheets("sheet1").Cells(1, i + 5) & "(" & Sheets("sheet1").Cells(r, i + 5) & ")" & "," End If Next i