It is a little bit more complex than recording a macro. Here is one way to do it. The following example assumes:
The Team Names are in column A beginning in row 2
The number of wins is in column B beginning in row 2
The number of losses is in column C beginning in row 2
Enter Headings in A1:E1:
Team
Wins
Losses
Pct
GB
Enter all Team names in column A.
Select cells D2 through the last row containing a team name in column A.
Format the cells as Number, with 3 decimal places.
In cell D2 enter the formula:
=IF(AND(B2<>"",C2<>""),B2/(B2+C2),"")
Drag the formula down through the last row containing a team name.
In Cell E3 enter the formula:
=IF(B3="","", IF(SUM($B$2-B3+C3-$C$2)=0, "",(($B$2-B3)+(C3-$C$2))/2))
Copy this formula down through the last row containing a Team name in column A.
Next, copy the following code to the clipboard:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim LastRow
curCell = ActiveCell.Address
LastRow = Range("A" & Rows.Count).End(xlUp).Row
For Each cell In Range("A2:C" & LastRow)
If cell.Value = "" Then
Exit Sub
End If
Next
Application.ScreenUpdating = False
Range("A2:D" & LastRow).Select
Selection.Sort Key1:=Range("D1"), Order1:=xlDescending, _
Key2:=Range("A1"), Order2:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal
Range(curCell).Select
End Sub
Select the appropriate worksheet and right click the sheet tab.
Select 'View Code'
Paste the code into the sheet module editing area to the right.
In the menus at the top of the VBE, select INSERT > MODULE
Copy the following code and paste it into the newly created module;
Public curCell
Close the VBE and return to the worksheet.
Enter your wins and losses. Once each team has a won/lost record, the macro will automatically sort by the Won/Lost percentage calculated in column D.
The 'Games Behind' will be calculated and displayed in column E.
If two teams have the same record, they will be sorted alphabetically by team name.
If, by some chance you need to add a team, the macro will self adjust to the new sort range. You will, however, have to drag the formulas in columns D and E down through the new last row.
I have tested this and it works appropriately. Again, the macro will not initially sort until there is a value in every team's Wins and Losses column.