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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting in Excel using VBScript

Status
Not open for further replies.

bstewart

Technical User
Dec 5, 2001
1
US
I am new to VBScript but impressed with its the power.
I am trying to sort three columns of data in Excel using VB Script. By cheating using Excel, I recorded a marco and viewed the results in the VB Editor. I get these results

Rows("1:1").Select
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Key2:=Range("C2") _
, Order2:=xlAscending, Key3:=Range("D2"), Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub

I think in VBScript the sort starts something like this

objXL.Rows(1, 1).Select
objXL.Selection.Sort

Stuck after this

Thanks
 
I would go back into the VB editor, edit the macro, start a Sub and
start typing
objXL.Rows(1, 1).Select and then a blank or left paren
and let Intellisense give me the argument list.
Try the same thing with
objXL.Selection.Sort

P.S. It "ain't cheatin'", it is called working smart.
Compare Code (Text)
Generate Sort in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top