Hi shinobi09
I'm not much good at formulas so I did a VBA solution. As it is now it pastes the results onto sheet 2 but the code can be changed to paste it anywhere.
There's a button on Sheet 1 to press to see what it does & if it's what you want etc. If you like it it can be changed to a worksheet change macro so no button pressing will be required.
Let me know if you want it changed etc
The website STILL WONT LET ME UPLOAD A WORKBOOK. Not shouting at you, shouting at the people who ain't doing anything about it.
A dropbox link is below to download
https://www.dropbox.com/s/qm7k5mgfxr...late.xlsb?dl=0
Option Explicit
Sub HighScores()
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With
Dim Ws1 As Worksheet, Ws2 As Worksheet
Dim TheWholeRange As Range, Top4Range As Range
Dim WsBotRow As Long, Xx As Long, Zz As Long
Set Ws1 = ThisWorkbook.Sheets(1)
Set Ws2 = ThisWorkbook.Sheets(2)
Set Top4Range = Ws1.Range("B6:G9")
Xx = 3
' Find bottom row number in column (G) Ws5
WsBotRow = Ws1.Columns(2).Find(What:="*", LookIn:=xlValues, _
lookat:=xlPart, SearchOrder:=xlByRows, searchdirection:=xlPrevious, _
MatchCase:=False, searchformat:=False).Row
' Don't have to clear the old top 4 scores, but we will
Union(Ws2.Range("B3:G6"), Ws2.Range("B9:G12"), Ws2.Range("B15:G18")).ClearContents
Set TheWholeRange = Ws1.Range("B6:G" & WsBotRow)
Ws1.Sort.SortFields.Clear
For Zz = 1 To 3
If Xx = 3 Then
' Sort the range with females at the top
With TheWholeRange
TheWholeRange.Sort key1:=Ws1.Range("C6"), Order1:=xlAscending, Key2:=Ws1.Range("D6"), _
Order2:=xlDescending, Header:=xlGuess, MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
End With
ElseIf Xx = 9 Then
' Sort the range with males at the top
With TheWholeRange
TheWholeRange.Sort key1:=Ws1.Range("C6"), Order1:=xlDescending, Key2:=Ws1.Range("D6"), _
Order2:=xlDescending, Header:=xlGuess, MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
End With
ElseIf Xx = 15 Then
' Sort the range into highest score at the top
With TheWholeRange
TheWholeRange.Sort key1:=Ws1.Range("D6"), Order1:=xlDescending, Header:=xlGuess, _
MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
End With
End If
Top4Range.Copy ' Copy the top 4 results
With Ws2.Cells(Xx, 2) ' Paste results to sheet 2
.PasteSpecial xlPasteValues
.Font.Name = "Calibri"
.Font.Size = 10
.Font.Bold = False
End With
Application.CutCopyMode = False
Xx = Xx + 6
Next Zz
' Tidy up
With Ws2
.Activate
.Range("A1").Activate ' Gets rid of the selection of last paste range
End With
Ws1.Sort.SortFields.Clear
Ws2.Range("B3:G18").Columns.AutoFit
With Application
.Calculation = xlCalculationAutomatic
.DisplayAlerts = True
.EnableEvents = True
.ScreenUpdating = True
End With
Exit Sub
End Sub
Bookmarks