Auto sorting in Excel

MyiagrosMyiagros Registered User regular
edited November 2012 in Help / Advice Forum
I'm doing stat tracking for my hockey league since the site we went through in previous years decided to charge to use it. I've got a good looking Excel file with auto updating standing and stat leader pages that I'd like to have auto sort whenever a change is made to them. I've created two macros which I can run manually and they do the sorting the way I want it to but search efforts to find a way for them to trigger with the Worksheet_Change function is not bringing up something that works.

Some more details of the file since I think it might be the way it works that it causing the problems:
8 worksheets - Standings, Stat Leaders, Team 1 through Team 6.
I input stats into the Team pages which then autofills the Standings and Stat Leader pages. I'd like these two pages to auto sort when I make changes on the Team worksheets as that's the only spot I enter the info..

Here's one of the macros, I would assume if this one gets figured out I can do the same for the other. Where do I drop this, or how do I activate it on the worksheet? After creating the macro it is just shown under the Modules -> Module1 tab.
Sub StandingsSort()
'
' StandingsSort Macro
' Sorts the team standings
'

'
Range("B2:I7").Select
ActiveWorkbook.Worksheets("Standings").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Standings").Sort.SortFields.Add Key:=Range("F2:F7" _
), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Standings").Sort.SortFields.Add Key:=Range("C2:C7" _
), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Standings").Sort.SortFields.Add Key:=Range("D2:D7" _
), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Standings").Sort.SortFields.Add Key:=Range("G2:G7" _
), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Standings").Sort.SortFields.Add Key:=Range("H2:H7" _
), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Standings").Sort.SortFields.Add Key:=Range("I2:I7" _
), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Standings").Sort
.SetRange Range("B2:I7")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub

iRevert wrote: »
Because if you're going to attempt to squeeze that big black monster into your slot you will need to be able to take at least 12 inches or else you're going to have a bad time...
Steam: MyiagrosX27
Myiagros on
Sign In or Register to comment.