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

Sort Function Parameters 1

Status
Not open for further replies.

mavest

Programmer
Feb 27, 2003
54
US
I need to understand the parameters passed to the Excel Sort function when called by VBA. If I use my object viewer and find Sort as a member of Range, I get the following list of parameters.

Function Sort([Key1], [Order1 As XlSortOrder = xlAscending], [Key2],
[Type], [Order2 As XlSortOrder = xlAscending], [Key3],
[Order3 As XlSortOrder = xlAscending], [Header As XlYesNoGuess = xlNo],
[OrderCustom], [MatchCase], [Orientation As XlSortOrientation = xlSortRows],
[SortMethod As XlSortMethod = xlPinYin],
[DataOption1 As XlSortDataOption = xlSortNormal],
[DataOption2 As XlSortDataOption = xlSortNormal],
[DataOption3 As XlSortDataOption = xlSortNormal])
Member of Excel.Range

You will notice that the 4th parameter is Type. Does anyone know what data_type the parameter type is. I've had difficultly finding an explanation of the parameters. Thanks a bunch!!!

-Mike

P.S. a typical syntax to call this function from VBA is

Worksheets("Sheet1").Range("A2:Z10").Sort Key1:=Cells(1, 1), Order1:=xlAscending

I haven't seen a VB program example that makes use of the type parameter.
 
Hi mavest,

From Help on the Sort Method ...

Type Optional Variant. Specifies which elements are sorted. Can be one of the following XlSortType constants: xlSortValues or xlSortLabels. Used only when sorting PivotTables.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
Tony,

Thanks, you've told me exactly what I need to know and sorry to bother you with something that is in help, but my employer hasn't given me the help files!! I could probably have found it on the MSN.

I actually will not be calling sort through VBA, but through an OLE package used by a language called REXX. This package requires that the parameters be specified in order, and so I have to specify TYPE even though I am not making use of it. I think I will also try a ',' space holder. My testing Friday got the sort working for 1 and 2 columns, but could not work for 3 because of the TYPE parameter!

Before I develop the command in REXX, I develop it in VBA so I have a starting point. Thanks!!
 
Hi mavest,

Glad I could help. Why, I wonder, are programmers expected to work with one hand tied behind their back? - it used to be the case that companies wouldn't fork out for the manuals, now they don't install help files. Anyway, enjoy Rexx - I do.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top