I'm not a VBA or Excel expert, but I thought the code below was pretty simple. It basically sorts a range of cells everytime a value on the sheet changes. It worked perfectly in Excel 2003, but in Excel 2007 nothing happens. Does anyone have any idea if there is an incompatibility, or maybe something in 2007 that I need to enable for this to work?
Private Sub Worksheet_Change(ByVal Target As Range)
With Worksheets("LeaderBoard")
.Range("C4:E28").Sort Key1:=.Range("D4"), Order1:=xlDescending, Key2:=.Range("E4"), Order2:=xlDescending, Header:=xlNo, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
.Range("H4:J28").Sort Key1:=.Range("I4"), Order1:=xlDescending, Key2:=.Range("J4"), Order2:=xlDescending, Header:=xlNo, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End With
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
With Worksheets("LeaderBoard")
.Range("C4:E28").Sort Key1:=.Range("D4"), Order1:=xlDescending, Key2:=.Range("E4"), Order2:=xlDescending, Header:=xlNo, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
.Range("H4:J28").Sort Key1:=.Range("I4"), Order1:=xlDescending, Key2:=.Range("J4"), Order2:=xlDescending, Header:=xlNo, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End With
End Sub