Krishna2385
New Member
Hi I have a MACRO recorded for a custom sort list. can I get the same in VBA coding.
am pasting my macro and need the same to be in VBA coding, I was told that there will be difference in macro recording to write up the VBA code
Sub sort()
'
' sort Macro
'
'
Selection.AutoFilter
Application.DeleteCustomList ListNum:=6
Application.AddCustomList ListArray:=Array("Tier 4", "Tier 3", "Tier 2", _
"Tier 1")
ActiveWorkbook.Worksheets("eGRC").AutoFilter.sort.SortFields.Clear
ActiveWorkbook.Worksheets("eGRC").AutoFilter.sort.SortFields.Add Key:=Range( _
"A2:A12140"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("eGRC").AutoFilter.sort.SortFields.Add Key:=Range( _
"D2:D12140"), SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:= _
"Tier 4,Tier 3,Tier 2,Tier 1", DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("eGRC").AutoFilter.sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
am pasting my macro and need the same to be in VBA coding, I was told that there will be difference in macro recording to write up the VBA code
Sub sort()
'
' sort Macro
'
'
Selection.AutoFilter
Application.DeleteCustomList ListNum:=6
Application.AddCustomList ListArray:=Array("Tier 4", "Tier 3", "Tier 2", _
"Tier 1")
ActiveWorkbook.Worksheets("eGRC").AutoFilter.sort.SortFields.Clear
ActiveWorkbook.Worksheets("eGRC").AutoFilter.sort.SortFields.Add Key:=Range( _
"A2:A12140"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("eGRC").AutoFilter.sort.SortFields.Add Key:=Range( _
"D2:D12140"), SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:= _
"Tier 4,Tier 3,Tier 2,Tier 1", DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("eGRC").AutoFilter.sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub