Hi there,
Take a look at the attached version of your workbook and see if it does what you need. It uses the following code:
Option Explicit
Private Sub UpdateLeaderboard()
Const iNO_OF_COLUMNS As Integer = 3
Const iNO_OF_TEAMS As Integer = 20
Const iRANK_COLUMN As Integer = 3
Const sSHEET_NAME As String = "Leaderboard"
Const sFIRST_CELL As String = "B4"
Dim rRangeToSort As Range
Dim rFirstCell As Range
Dim wks As Worksheet
Set wks = ThisWorkbook.Worksheets(sSHEET_NAME)
Set rFirstCell = wks.Range(sFIRST_CELL)
With rFirstCell
Set rRangeToSort = Range(.Cells(1, 1), _
.Cells(iNO_OF_TEAMS, iNO_OF_COLUMNS))
End With
With rRangeToSort
.Sort Key1:=.Cells(1, iRANK_COLUMN), order1:=xlAscending, Header:=xlNo
End With
End Sub
The highlighted values may be altered to suit your requirements.
The ranking on the Leaderboard worksheet updates automatically because the following formula has been entered in Cell D4 and copied downwards:
=VLOOKUP(B4, Scoreboard!B4:D23, 3, FALSE)
Hope this helps - please let me know how you get on.
Regards,
Greg M
Bookmarks