I have a macro to sort a named range that works well but I need to have it run every time when a user leaves the active sheet. That way if they change anything in the named range, when they leave that sheet, it will re-sort that range. The code below is what I have to sort the range.
If anyone can help with my question or can simplify my code below, I would be so grateful.
RR
Sheets("Project Role").Select
Application.Goto Reference:="R3C2"
Range(Selection, Selection.End(xlDown)).Select
Range("B3:B42").Select
ActiveWorkbook.Worksheets("Project Role").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Project Role").Sort.SortFields.Add Key:=Range("B3" _
), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortTextAsNumbers
With ActiveWorkbook.Worksheets("Project Role").Sort
.SetRange Range("B4:B42")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A1").Select
Bookmarks