+ Reply to Thread
Results 1 to 4 of 4

Finding row number of top 3 entries

Hybrid View

  1. #1
    Registered User
    Join Date
    08-21-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    21

    Finding row number of top 3 entries

    My data file is in the attached format

    Using VBA, I need the row numbers of all the companys with top 3 EBITDA.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Finding row number of top 3 entries

    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.

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,995

    Re: Finding row number of top 3 entries

    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.
    Attached Files Attached Files
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Registered User
    Join Date
    08-21-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Finding row number of top 3 entries

    Quote Originally Posted by 6StringJazzer View Post
    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.
    Sorry for not responding for so long..
    I had to shelve that part of the project so I have not tried out the solutions provided by you guys..

    thanks for helping ..

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1