Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5
Default I need a sort to descend and ascend simultaneously

I have a "date column" (Column A) with this formula structure in all of the
rows of that column =IF($M20,$M2,IF($M2=0,"NA")). It feeds off of a revision
date column (column M). If there is no date in the "revision date column" it
shows up NA in column A. All of the NA's and dates are recorded in column A
through this formula.

Then I sort column A with a sort command button located at the top of column
A with this formula:
Private Sub CommandButton1_Click()
Range("A2").Sort Key1:=Range("A2"), Order1:= _
xlAscending, Header:=xlGuess, OrderCustom:=6, _
MatchCase:=False, Orientation:=xlTopToBottom
End Sub

This sorts the dates in ascending order with the NA's at the bottom.I need
to know if there is a formula that will allow me to sort column A with all of
the NA's rising to the top but the rest of the dates falling in ascending
order below the NA's. Is this feasible and did I explain it clearly?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,344
Default I need a sort to descend and ascend simultaneously

Here's one way:

Change your formula from

=IF($M20,$M2,IF($M2=0,"NA"))

to

=IF($M20,$M2,IF($M2=0,1))

Create the following custom format and apply it to the whole column:

[=1]"N/A";m/d/yyyy

Of course the cells won't really contain N/A which may be a problem
depending on what you're doing.
--
Cheers,
Shane Devenshire


"Irishimp23" wrote:

I have a "date column" (Column A) with this formula structure in all of the
rows of that column =IF($M20,$M2,IF($M2=0,"NA")). It feeds off of a revision
date column (column M). If there is no date in the "revision date column" it
shows up NA in column A. All of the NA's and dates are recorded in column A
through this formula.

Then I sort column A with a sort command button located at the top of column
A with this formula:
Private Sub CommandButton1_Click()
Range("A2").Sort Key1:=Range("A2"), Order1:= _
xlAscending, Header:=xlGuess, OrderCustom:=6, _
MatchCase:=False, Orientation:=xlTopToBottom
End Sub

This sorts the dates in ascending order with the NA's at the bottom.I need
to know if there is a formula that will allow me to sort column A with all of
the NA's rising to the top but the rest of the dates falling in ascending
order below the NA's. Is this feasible and did I explain it clearly?

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5
Default I need a sort to descend and ascend simultaneously

It worked perfectly! Thank You :)

"ShaneDevenshire" wrote:

Here's one way:

Change your formula from

=IF($M20,$M2,IF($M2=0,"NA"))

to

=IF($M20,$M2,IF($M2=0,1))

Create the following custom format and apply it to the whole column:

[=1]"N/A";m/d/yyyy

Of course the cells won't really contain N/A which may be a problem
depending on what you're doing.
--
Cheers,
Shane Devenshire


"Irishimp23" wrote:

I have a "date column" (Column A) with this formula structure in all of the
rows of that column =IF($M20,$M2,IF($M2=0,"NA")). It feeds off of a revision
date column (column M). If there is no date in the "revision date column" it
shows up NA in column A. All of the NA's and dates are recorded in column A
through this formula.

Then I sort column A with a sort command button located at the top of column
A with this formula:
Private Sub CommandButton1_Click()
Range("A2").Sort Key1:=Range("A2"), Order1:= _
xlAscending, Header:=xlGuess, OrderCustom:=6, _
MatchCase:=False, Orientation:=xlTopToBottom
End Sub

This sorts the dates in ascending order with the NA's at the bottom.I need
to know if there is a formula that will allow me to sort column A with all of
the NA's rising to the top but the rest of the dates falling in ascending
order below the NA's. Is this feasible and did I explain it clearly?

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 733
Default I need a sort to descend and ascend simultaneously

ShaneDevenshire wrote...
Here's one way:

Change your formula from

=IF($M20,$M2,IF($M2=0,"NA"))

to

=IF($M20,$M2,IF($M2=0,1))

Create the following custom format and apply it to the whole column:

[=1]"N/A";m/d/yyyy

....

Why not leave the column A formulas as-is and sort on column M?

Or make the column A formulas simple, e.g., A2: =M2 and format using

[=0]"NA";mm/dd/yyyy

? If these records sort correctly with missing column M values as 1 in
column A, they'd also sort correctly with missing column M values as 0
in column A.

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



All times are GMT +1. The time now is 06:59 PM.

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

About Us

"It's about Microsoft Excel"