Hi All,
Copying code from vba to vbscript did not quite work. I was hoping if anyone could give me a hand. The purpose of the code is to sort the selection so that the smallest value is on the top. I was wondering if there is a way to make this work. Thanks!
This is the original vba code.
This is vbscript.
The vbs script has a "bad index" error starting on line 3.
With Best Regards,
Suggz
Copying code from vba to vbscript did not quite work. I was hoping if anyone could give me a hand. The purpose of the code is to sort the selection so that the smallest value is on the top. I was wondering if there is a way to make this work. Thanks!
This is the original vba code.
Code:
Range("F1").Select Application.CutCopyMode = False ActiveWorkbook.Worksheets("Sheet3").Sort.SortFields.Clear ActiveWorkbook.Worksheets("Sheet3").Sort.SortFields.Add Key:=Range("F1"), _ SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal With ActiveWorkbook.Worksheets("Sheet3").Sort .SetRange Range("F1:I49") .Header = xlNo .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With
Code:
oExcel.Range("F1").Select oExcel.Application.CutCopyMode = False oExcel.ActiveWorkbook.Worksheets("Sheet3").Sort.SortFields.Clear oExcel.ActiveWorkbook.Worksheets("Sheet3").Sort.SortFields.Add Key:=Range("F1"), _ SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal With oExcel.ActiveWorkbook.Worksheets("Sheet3").Sort .SetRange Range("F1:I49") .Header = xlNo .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With
With Best Regards,
Suggz