ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sorting Issues (https://www.excelbanter.com/excel-programming/396323-sorting-issues.html)

Dean[_8_]

Sorting Issues
 
I inherited a macro that sorts in descending order (the first key, actually,
I am happy to eliminate the 2nd key if that helps), but seems to put any
blank entries (first key and 2nd key are either both blank or non-blank, I
think) at the top, whereas I would prefer they be ignored or, if that is
difficult, be put at the bottom. I would think, considering the first sort
is a descending number , that a blank would be put at the bottom, but I
guess I am wrong since they seem to be at the top. Here is the macro:

Selection.Sort Key1:=Range("P18"), Order1:=xlDescending, Key2:=Range( _
"N18"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1,
MatchCase _
:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal

I cannot seem to figure out how to change this if I do it manually in EXCEL,
so perhaps there is no easy way, in which case I need to be more creative,
such as assigning zeroes instead of blanks, and then somehow eliminating the
zeroes later.

Thanks
Dean



JLGWhiz

Sorting Issues
 
According to the Excel help file for default sort order, blanks should be
last for Ascending or Descending order. Only visible characters and space
are reversed, so maybe those are spaces instead of blanks.

"Dean" wrote:

I inherited a macro that sorts in descending order (the first key, actually,
I am happy to eliminate the 2nd key if that helps), but seems to put any
blank entries (first key and 2nd key are either both blank or non-blank, I
think) at the top, whereas I would prefer they be ignored or, if that is
difficult, be put at the bottom. I would think, considering the first sort
is a descending number , that a blank would be put at the bottom, but I
guess I am wrong since they seem to be at the top. Here is the macro:

Selection.Sort Key1:=Range("P18"), Order1:=xlDescending, Key2:=Range( _
"N18"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1,
MatchCase _
:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal

I cannot seem to figure out how to change this if I do it manually in EXCEL,
so perhaps there is no easy way, in which case I need to be more creative,
such as assigning zeroes instead of blanks, and then somehow eliminating the
zeroes later.

Thanks
Dean




Dean[_8_]

Sorting Issues
 
Let me check into that. Thanks.

"JLGWhiz" wrote in message
...
According to the Excel help file for default sort order, blanks should be
last for Ascending or Descending order. Only visible characters and space
are reversed, so maybe those are spaces instead of blanks.

"Dean" wrote:

I inherited a macro that sorts in descending order (the first key,
actually,
I am happy to eliminate the 2nd key if that helps), but seems to put any
blank entries (first key and 2nd key are either both blank or non-blank,
I
think) at the top, whereas I would prefer they be ignored or, if that is
difficult, be put at the bottom. I would think, considering the first
sort
is a descending number , that a blank would be put at the bottom, but I
guess I am wrong since they seem to be at the top. Here is the macro:

Selection.Sort Key1:=Range("P18"), Order1:=xlDescending, Key2:=Range( _
"N18"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1,
MatchCase _
:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal

I cannot seem to figure out how to change this if I do it manually in
EXCEL,
so perhaps there is no easy way, in which case I need to be more
creative,
such as assigning zeroes instead of blanks, and then somehow eliminating
the
zeroes later.

Thanks
Dean







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

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