The code I have applied is as below, purpose being to sort over target worksheet range A:H using A,B,C,D as sort field in that order. The code does the purpose, but after code execution, the screen ends at range A:H being selected. I would want to clear the selection.
As you see I have tried using
wsName.Range("A1").Select
Application.CutCopyMode = False
at the end, but not quite working as I expected.
Public Sub sSortColumn(wsName As Worksheet)
With wsName.Sort
With .SortFields
.Clear
.Add Key:=Range("A:A"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.Add Key:=Range("B:B"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.Add Key:=Range("C:C"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.Add Key:=Range("D:D"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
End With
.SetRange Range("A:H")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
wsName.Sort.SortFields.Clear
wsName.Range("A1").Select
Application.CutCopyMode = False
End Sub`