Macro needed

Avdberg

New Member
Joined
May 11, 2017
Messages
13
Hi,
Would you please be so kind and assist me with a macro to extract specific data within a spreadsheet. The specs are. I have a list of students 30+ who rights exams every week and I want to extract the top 3 marks and names each week. Should there be more than 3 student with the same mark in the top 3 then I want to see all those students even if it's more that 3. Below is a example of how I did it manually.

[TABLE="width: 272"]
<tbody>[TR]
[TD]Name[/TD]
[TD]week 1[/TD]
[TD] [/TD]
[TD] [/TD]
[TD]week 2[/TD]
[TD] [/TD]
[TD] [/TD]
[TD]week 3[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Anna[/TD]
[TD="align: right"]21[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]25[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]23[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Carl[/TD]
[TD="align: right"]18[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]20[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]19[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Jill[/TD]
[TD="align: right"]16[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]21[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]29[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]John[/TD]
[TD="align: right"]27[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]25[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]23[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Liz[/TD]
[TD="align: right"]19[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]22[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]21[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Peter[/TD]
[TD="align: right"]29[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]25[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]27[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Sandra[/TD]
[TD="align: right"]25[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]25[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]22[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Susan[/TD]
[TD="align: right"]20[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]23[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]19[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Tim[/TD]
[TD="align: right"]24[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]25[/TD]
[TD] [/TD]
[TD] [/TD]
[TD="align: right"]20[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]Peter[/TD]
[TD="align: right"]29[/TD]
[TD] [/TD]
[TD]Anna[/TD]
[TD="align: right"]25[/TD]
[TD] [/TD]
[TD]Jill[/TD]
[TD="align: right"]29[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]John[/TD]
[TD="align: right"]27[/TD]
[TD] [/TD]
[TD]John[/TD]
[TD="align: right"]25[/TD]
[TD] [/TD]
[TD]Peter[/TD]
[TD="align: right"]27[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD]Sandra[/TD]
[TD="align: right"]25[/TD]
[TD] [/TD]
[TD]Peter[/TD]
[TD="align: right"]25[/TD]
[TD] [/TD]
[TD]Anna[/TD]
[TD="align: right"]23[/TD]
[/TR]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD][/TD]
[TD] [/TD]
[TD]Sandra[/TD]
[TD="align: right"]25[/TD]
[TD] [/TD]
[TD]John[/TD]
[TD="align: right"]23[/TD]
[/TR]
[TR]
[TD]
Thank you [/TD]
[TD] [/TD]
[TD][/TD]
[TD] [/TD]
[TD]Tim[/TD]
[TD="align: right"]25[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
</tbody><colgroup><col><col><col><col><col><col><col><col><col></colgroup>[/TABLE]
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
a macro to extract specific data within a spreadsheet.

Hi, I wonder if you can be tempted with a formula based option.

The formulas in F2:G2 are copied down as far as might be required, the whole table in F:G is copied to I:J and L:M and only the week number needs changing to affect the updated results.


Excel 2013/2016
ABCDEFGHIJKLM
1Nameweek 1week 2week 3Week 13Week 25Week 34
2Anna212523Peter29Anna25Jill29
3Carl182019John27John25Peter27
4Jill162129Sandra25Peter25Anna23
5John272523Sandra25John23
6Liz192221Tim25
7Peter292527
8Sandra252522
9Susan202319
10Tim242520
Sheet1
Cell Formulas
RangeFormula
G1=COUNTIFS(INDEX($B$2:$D$50,0,MATCH(F1,$B$1:$D$1,0)),">="&LARGE(INDEX($B$2:$D$50,0,MATCH(F1,$B$1:$D$1,0)),3))
G2=IF(ROWS(G$2:G2)>G$1,"",LARGE(INDEX($B$2:$D$50,0,MATCH(F$1,$B$1:$D$1,0)),ROWS(G$2:G2)))
F2=IF(G2="","",INDEX($A$2:$A$50,AGGREGATE(15,6,(ROW($A$2:$A$50)-ROW($A$2)+1)/(INDEX($B$2:$D$50,0,MATCH(F$1,$B$1:$D$1,0))=G2),COUNTIFS(G$2:G2,G2))))
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,316
Members
452,634
Latest member
cpostell

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