ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Simple Sort question (https://www.excelbanter.com/excel-programming/277218-simple-sort-question.html)

TBA[_2_]

Simple Sort question
 
Excel 97
Windows 2k Pro

I know that using Excel's built in Sort menu option that I can only sort up
to three columns at a time. I went ahead and recorded a sort as a macro to
get the basic code for doing this in VBA, so I was wondering if I can add a
4th, 5th or 6th sort key in the VBA code for the Macro. I've tried doing
this by mimicking the code but adding a 4th key, using the same syntax as
the macro code, but I got an "unknown object" error. Is it just not meant
to be?

-gk-



Debra Dalgleish[_2_]

Simple Sort question
 
You can record the steps as you perform multiple sorts. For example, you
may want to sort by Country, Region, City, LastName and FirstName.

LastName and FirstName are the least important fields in the sorting
process, so they can be sorted first. (DataSort, By LastName, then by
FirstName)

Then sort the remaining fields (By Country, then by Region, then by
City). Excel will retain as much as possible from the earlier sorts.


TBA wrote:
Excel 97
Windows 2k Pro

I know that using Excel's built in Sort menu option that I can only sort up
to three columns at a time. I went ahead and recorded a sort as a macro to
get the basic code for doing this in VBA, so I was wondering if I can add a
4th, 5th or 6th sort key in the VBA code for the Macro. I've tried doing
this by mimicking the code but adding a 4th key, using the same syntax as
the macro code, but I got an "unknown object" error. Is it just not meant
to be?


--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html


Alan Beban[_3_]

Simple Sort question
 
If the functions in the freely downloadable file at
http://home.pacbell.net/beban are available to your workbook, you can
nest the ArrayRowFilter functions:

=ArrayRowFilter2(ArrayRowFilter1(ArrayRowFilter1(A rrayRowFilter1(ArrayRowFilter1(ArrayRowFilter1(dat arange,1stCol,1stCrit),2ndCol,2ndCrit),3rdCol,3rdC rit),4thCol,4thCrit),5thCol,5thCrit),6thCol,6thCri t)
array entered into a range sufficiently large to accommodate the final
output. Note that the first function is ArrayRowFilter2, the remainder
are ArrayRowFilter1. This is to avoid getting an error message if the
selected range is large enough for the final output but not large enough
for an intermediate output. If the selected range is not large enough
for the final output, the error message will indicate the range size to
be selected.

Alan Beban

TBA wrote:
Excel 97
Windows 2k Pro

I know that using Excel's built in Sort menu option that I can only sort up
to three columns at a time. I went ahead and recorded a sort as a macro to
get the basic code for doing this in VBA, so I was wondering if I can add a
4th, 5th or 6th sort key in the VBA code for the Macro. I've tried doing
this by mimicking the code but adding a 4th key, using the same syntax as
the macro code, but I got an "unknown object" error. Is it just not meant
to be?

-gk-





All times are GMT +1. The time now is 05:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com