Hi,

I would like to sort some columns alphabetically when deactivating a sheet. If I use the Worksheet_Deactivate command to trigger the macro then it immediately needs activating again to do the sorting, hence an infinite loop is started.

So far I have:

Private Sub Worksheet_Deactivate()

Application.ScreenUpdating = False

Worksheets("Data Library").Columns("C:X").Select
Selection.Sort Key1:=Range("C2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, _
DataOption1:=xlSortNormal
ActiveWindow.LargeScroll ToRight:=-1

Application.ScreenUpdating = True

End Sub

This fails to run on the 'Worksheets..' line.

Please can anybody help?