VBA- Finding Highest Value and Matching to Names in other column.

ddaavidd_david

New Member
Joined
Jan 29, 2019
Messages
1
I have a question which says: "Refer to the "Final Marks" column (Column N) and find the student with the highest mark. Display the student name (from Column D) into the cell Q2. Answer should be in the form of VBA codes."

I have managed to do this using Excel function =INDEX(D2:D296,MATCH(MAX(N2:N296),N2:N296,0))
How do I convert that into VBA codes?
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Please use a larger font for readability.

Code:
Sub transferdata()
With Workbooks("REFERENCE").Sheets("REFERENCE")

Set FindHighesMark = .Range("N10:N50").Find(Application.WorksheetFunction.Max(Columns("M")), lookat:=xlWhole, MatchCase:=False).Row

.Range("Q2:Q5").Value = .Cells(FindHighestMark, "D")

End With
End Sub

But, I don't think it's fair that you let us do your homework
 
Last edited:
Upvote 0
Hi. You should really do your own homework. You dont gain much from being fed an answer. Id use a combination of max, match and offset for that i think but not in the form of a worksheet formula.
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,164
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top