Forum Discussion
How to get top 3 employee name who are top scorer in Message Box using VBA
Hi Team..I want to get top 3 Emp Name along with top 3 bids who has top bids using VBA code. I have written a code to get top 3 bids I can get top 3 bids but not able to get Emp Name in same Msg Box...Please look into the code and help me with Empname who has top bids in the given data.
Code:-
Sub Top_Bids()
Dim myrange As range
Dim Top1 As Double, Top2 As Double, Top3 As Double
On Error GoTo leave
Set myrange = Excel.Application.Inputbox(Prompt:="Please select a range to get top 3 value", Title:="Top 3 Bids", Type:=8)
If Application.WorksheetFunction.Count(myrange) > 2 Then
Top1 = Excel.Application.WorksheetFunction.Large(myrange, 1)
Top2 = Excel.Application.WorksheetFunction.Large(myrange, 2)
Top3 = Excel.Application.WorksheetFunction.Large(myrange, 3)
MsgBox " Top1 = " & Top1 & vbNewLine & " Top2 = " & Top2 & vbNewLine & " Top3 = " & Top3, Title:="Top 3 Bids!"
Else
MsgBox "Please Select Atleast 3 Cells to Get Top 3 Value", vbInformation
End If
leave:
End Sub
4 Replies
- NikolinoDEPlatinum Contributor
In German:
Hier eine Seite wo Sie eventuelle anregungen finden können für Ihr vorhaben.
Clevere Auswertungen per VBA mit dem AutoFilter von Excel
Würde mich freuen wenn es Ihnen geholfen hat.
Nikolino
Ich weiss das ich nicht weiss (sokrates)
- mathetesGold Contributor
This resource may give you a non-VBA method. https://exceljet.net/lessons/how-to-show-top-or-bottom-n-results
- SONIKA_RAOCopper ContributorHi..Thanks for the help but I am not looking for an Excel solution,looking for a VBA solution.
- mathetesGold Contributor
OK. Best wishes....I'm not a VBA person.....so one of the other folks around here is going to have to jump in.
In general, I've always been happier when I find a way to accomplish my goal using Excel's amazing array of functions. In some instances, I've been able, doing that, to replace elaborate VBA/macro solutions with Excel functions that operate faster and more accurately by orders of magnitude.
Which isn't to say that there aren't times when VBA is necessary. But so far, I've survived with minimal use of it, and that years ago.