Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to do custom sort in vb script

Status
Not open for further replies.

Baskar53

Programmer
Jun 7, 2019
2
0
0
US
hi,

i have done code to custom sort in VBA i need this code in vb script can help on this.

Sub Sort()
'
' Macro1 Macro
'

'
Range("C4").Select
Application.AddCustomList ListArray:=Array("AUTOU")
Application.DeleteCustomList ListNum:=6
Application.AddCustomList ListArray:=Array("AUTOU", "BOATU")
ActiveWorkbook.Worksheets("PAYOFF_REPORT").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("PAYOFF_REPORT").Sort.SortFields.Add2 Key:=Range( _
"C2:C26"), SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:= _
"AUTOU,BOATU,CYCLE,RV", DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("PAYOFF_REPORT").Sort
.SetRange Range("A1:S26")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
 
Convert to vbscript as in
1) You will get a syntax error on the := bits since vbscript does not have named arguments. You need to find out the order of the parameters in range and present them in that order:.
2) Find out from Excel what the values of the constants for xlYes, xlTopToBottom and xlPinYin are and either define the constants or use their numeric values.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top