Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Sort Orientation

Excel 2002, WinXP
I am sorting 27 columns and 156 rows with the following code:
..Range(.Cells(1, 1), .Cells(LastRow, LastCol)).Sort _
Key1:=.Range("C1"), _
Key2:=.Range("E1")

This abbreviated code sorts in ascending order by default, which is what I
want.

The Key1 column, Column C, is all formulas with many of the formulas
returning "blank" cells. My problem is that Excel is placing all of these
"blank" cells at the top after sorting. I want them to be at the bottom. I
have tried numerous variations of the variable parameters found in the long
Sort command to no avail.
Question: How do I code the Sort command to produce a sort in ascending
order, top to bottom, with the "blank" cells at the bottom?
I think I can do it with a Key1 helper column (Column #28) of =Len(Cx) in
descending order with Key2 (C) and Key3 (E) in ascending order, but is there
a better way? Thanks for your help. Otto


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Sort Orientation

That last idea, the =Len(Cx) isn't a good idea because it will mess up the
sort. I would have to modify that formula to produce either a 1 or a 0.
Otto
"Otto Moehrbach" wrote in message
...
Excel 2002, WinXP
I am sorting 27 columns and 156 rows with the following code:
.Range(.Cells(1, 1), .Cells(LastRow, LastCol)).Sort _
Key1:=.Range("C1"), _
Key2:=.Range("E1")

This abbreviated code sorts in ascending order by default, which is what I
want.

The Key1 column, Column C, is all formulas with many of the formulas
returning "blank" cells. My problem is that Excel is placing all of these
"blank" cells at the top after sorting. I want them to be at the bottom.

I
have tried numerous variations of the variable parameters found in the

long
Sort command to no avail.
Question: How do I code the Sort command to produce a sort in ascending
order, top to bottom, with the "blank" cells at the bottom?
I think I can do it with a Key1 helper column (Column #28) of =Len(Cx) in
descending order with Key2 (C) and Key3 (E) in ascending order, but is

there
a better way? Thanks for your help. Otto




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Sort Orientation

I'm not sure if it's better, but I think I'd just use a helper column that
evaluated to A or Z.

=if(c1="","Z","A")
fill that column.

and use that as a first key. Sort the data and then delete that helper column.



Otto Moehrbach wrote:

Excel 2002, WinXP
I am sorting 27 columns and 156 rows with the following code:
.Range(.Cells(1, 1), .Cells(LastRow, LastCol)).Sort _
Key1:=.Range("C1"), _
Key2:=.Range("E1")

This abbreviated code sorts in ascending order by default, which is what I
want.

The Key1 column, Column C, is all formulas with many of the formulas
returning "blank" cells. My problem is that Excel is placing all of these
"blank" cells at the top after sorting. I want them to be at the bottom. I
have tried numerous variations of the variable parameters found in the long
Sort command to no avail.
Question: How do I code the Sort command to produce a sort in ascending
order, top to bottom, with the "blank" cells at the bottom?
I think I can do it with a Key1 helper column (Column #28) of =Len(Cx) in
descending order with Key2 (C) and Key3 (E) in ascending order, but is there
a better way? Thanks for your help. Otto


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Sort Orientation

Thanks Dave. I'll do just that. Otto
"Dave Peterson" wrote in message
...
I'm not sure if it's better, but I think I'd just use a helper column that
evaluated to A or Z.

=if(c1="","Z","A")
fill that column.

and use that as a first key. Sort the data and then delete that helper

column.



Otto Moehrbach wrote:

Excel 2002, WinXP
I am sorting 27 columns and 156 rows with the following code:
.Range(.Cells(1, 1), .Cells(LastRow, LastCol)).Sort _
Key1:=.Range("C1"), _
Key2:=.Range("E1")

This abbreviated code sorts in ascending order by default, which is what

I
want.

The Key1 column, Column C, is all formulas with many of the formulas
returning "blank" cells. My problem is that Excel is placing all of

these
"blank" cells at the top after sorting. I want them to be at the

bottom. I
have tried numerous variations of the variable parameters found in the

long
Sort command to no avail.
Question: How do I code the Sort command to produce a sort in ascending
order, top to bottom, with the "blank" cells at the bottom?
I think I can do it with a Key1 helper column (Column #28) of =Len(Cx)

in
descending order with Key2 (C) and Key3 (E) in ascending order, but is

there
a better way? Thanks for your help. Otto


--

Dave Peterson



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pagesetup.Orientation need VBA routine to "Best Guess" Orientation [email protected] Excel Discussion (Misc queries) 3 November 10th 09 05:53 PM
Page Orientation Corey .... Setting up and Configuration of Excel 1 February 16th 09 03:46 PM
Comment orientation? Bob Newman Excel Discussion (Misc queries) 2 May 18th 08 12:35 AM
Page Orientation Karen Excel Discussion (Misc queries) 1 May 9th 06 08:54 PM
Haunted Orientation Hanna Mack Excel Discussion (Misc queries) 1 March 3rd 05 12:20 AM


All times are GMT +1. The time now is 08:30 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"