How to get top 3 employee name who are top scorer in Message Box using VBA

%3CLINGO-SUB%20id%3D%22lingo-sub-1678819%22%20slang%3D%22en-US%22%3EHow%20to%20get%20top%203%20employee%20name%20who%20are%20top%20scorer%20in%20Message%20Box%20using%20VBA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1678819%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22EmpName%20with%20top%203%20bids.png%22%20style%3D%22width%3A%20446px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F219160iAD60B6B55FDCB4FB%2Fimage-dimensions%2F446x215%3Fv%3D1.0%22%20width%3D%22446%22%20height%3D%22215%22%20title%3D%22EmpName%20with%20top%203%20bids.png%22%20alt%3D%22EmpName%20with%20top%203%20bids.png%22%20%2F%3E%3C%2FSPAN%3EHi%20Team..I%20want%20to%20get%20top%203%20Emp%20Name%26nbsp%3B%20along%20with%20top%203%20bids%20who%20has%20top%20bids%20using%20VBA%20code.%20I%20have%20written%20a%20code%20to%20get%20top%203%20bids%20I%20can%20get%20top%203%20bids%20but%20not%20able%20to%20get%20Emp%20Name%20in%20same%20Msg%20Box...Please%20look%20into%20the%20code%20and%20help%20me%20with%20Empname%20who%20has%20top%20bids%20in%20the%20given%20data.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECode%3A-%3C%2FP%3E%3CP%3ESub%20Top_Bids()%3C%2FP%3E%3CP%3EDim%20myrange%20As%20range%3CBR%20%2F%3EDim%20Top1%20As%20Double%2C%20Top2%20As%20Double%2C%20Top3%20As%20Double%3C%2FP%3E%3CP%3EOn%20Error%20GoTo%20leave%3CBR%20%2F%3ESet%20myrange%20%3D%20Excel.Application.Inputbox(Prompt%3A%3D%22Please%20select%20a%20range%20to%20get%20top%203%20value%22%2C%20Title%3A%3D%22Top%203%20Bids%22%2C%20Type%3A%3D8)%3CBR%20%2F%3EIf%20Application.WorksheetFunction.Count(myrange)%20%26gt%3B%202%20Then%3C%2FP%3E%3CP%3ETop1%20%3D%20Excel.Application.WorksheetFunction.Large(myrange%2C%201)%3CBR%20%2F%3ETop2%20%3D%20Excel.Application.WorksheetFunction.Large(myrange%2C%202)%3CBR%20%2F%3ETop3%20%3D%20Excel.Application.WorksheetFunction.Large(myrange%2C%203)%3CBR%20%2F%3EMsgBox%20%22%20Top1%20%3D%20%22%20%26amp%3B%20Top1%20%26amp%3B%20vbNewLine%20%26amp%3B%20%22%20Top2%20%3D%20%22%20%26amp%3B%20Top2%20%26amp%3B%20vbNewLine%20%26amp%3B%20%22%20Top3%20%3D%20%22%20%26amp%3B%20Top3%2C%20Title%3A%3D%22Top%203%20Bids!%22%3C%2FP%3E%3CP%3EElse%3C%2FP%3E%3CP%3EMsgBox%20%22Please%20Select%20Atleast%203%20Cells%20to%20Get%20Top%203%20Value%22%2C%20vbInformation%3C%2FP%3E%3CP%3EEnd%20If%3C%2FP%3E%3CP%3Eleave%3A%3C%2FP%3E%3CP%3EEnd%20Sub%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1678819%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1680194%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20get%20top%203%20employee%20name%20who%20are%20top%20scorer%20in%20Message%20Box%20using%20VBA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1680194%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F797350%22%20target%3D%22_blank%22%3E%40SONIKA_RAO%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20resource%20may%20give%20you%20a%20non-VBA%20method.%20%3CA%20href%3D%22https%3A%2F%2Fexceljet.net%2Flessons%2Fhow-to-show-top-or-bottom-n-results%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fexceljet.net%2Flessons%2Fhow-to-show-top-or-bottom-n-results%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1681732%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20get%20top%203%20employee%20name%20who%20are%20top%20scorer%20in%20Message%20Box%20using%20VBA%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1681732%22%20slang%3D%22en-US%22%3EHi..Thanks%20for%20the%20help%20but%20I%20am%20not%20looking%20for%20an%20Excel%20solution%2Clooking%20for%20a%20VBA%20solution.%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

EmpName with top 3 bids.pngHi 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
Highlighted
Highlighted
Hi..Thanks for the help but I am not looking for an Excel solution,looking for a VBA solution.

@SONIKA_RAO 

 

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.

Highlighted

@SONIKA_RAO 

 

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

https://www.informatik-aktuell.de/entwicklung/programmiersprachen/clevere-auswertungen-per-vba-mit-d...

 

 

Würde mich freuen wenn es Ihnen geholfen hat.

 

Nikolino

Ich weiss das ich nicht weiss (sokrates)