xl lists

  conrail 14:48 04 May 2007
Locked

using xp home, office xp, I have been asked by local football club to creat a spreadsheet of all results for season, ie date, opponents, score, points won, scorers, no problem there but they also want 3 lists, scorers and goals scored total, home only and away only list, again no problem, what I would like is advice on automatically sorting lists, ie if player a has scored 10 goals, player be 8, player c 7, etc. in the next match if player c scored 4 and player b 1 then the list would automatically put them in order, the list would have 3 columns, player, league goals, cup goals, total goals
thanks for all advice

  VoG II 15:30 04 May 2007

Assuming 4 columns

Player League Cup Total

and for the purpose of illustration I've assumed Row 1 contains those titles and then there are 10 players listed with their scores (yes - even I know that is not enough players but for illustration...):

Right click the Excel logo just to the left of File on the menu bar and select View Code. Copy the following and paste it into the code window:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Sheets("Sheet1").Range("A2:D11").Sort Key1:=Range("D2"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub

Adjust Range("A2:D11") to suit.

Now whenever you save the workbook your list will be sorted (even if you hit the Cancel button).

  conrail 17:21 05 May 2007

thanks VoG™, that'll make life easier

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

OnePlus 5 review

Alice Saey's mesmerising animation for Dutch singer Mark Lotterman

iPad Pro 10.5in (2017) review

Comment booster votre iPhone ?