My data file is in the attached format
Using VBA, I need the row numbers of all the companys with top 3 EBITDA.
My data file is in the attached format
Using VBA, I need the row numbers of all the companys with top 3 EBITDA.
try this
![]()
Sub max3() Dim i As Long, a As Long, y As Long Dim myrange As Range Dim mymax As Variant Dim kom As Variant a = Cells(Rows.Count, "d").End(xlUp).Row Set myrange = Range("d2:d" & a) y = 2 For i = 1 To 3 mymax = WorksheetFunction.Large(myrange, i) For Each kom In myrange If kom = mymax Then Range("i" & y) = kom.Row y = y + 1 End If Next Next End Sub
Regards
tom1977
If You are satisfied with my solution click the small star icon on the left to say thanks.
Any particular reason why it needs to be VBA? Are you using the list of row numbers in other code?
If you just need to display the data here is a non-VBA solution.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks