Sorting different types of data in 1 column

UniMord

Active Member
Joined
May 6, 2002
Messages
311
Hi! Can you help me with this?

I have a column "WHEN", the data type is Date. In the column, I have either dates or "ASAP". I'd like to sort the table in ascending order, with ASAP preceding the dates.

Thanks.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Not sure you can do that, try this macro, it will work as long as there is data in the last cell of the last column, you will have to change one line of it...

Sub Macro1()
'
Range("a1").Select
Selection.Sort Key1:=Range("A3"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("A2").Select
Do Until ActiveCell = Empty
If ActiveCell = "ASAP" Then
ActiveCell.Offset(1, 0).Select

Else
Dim firstdate
firstdate = ActiveCell.Address
Application.Goto Reference:="R65536C2" 'change to last column in table
Selection.End(xlUp).Select

Range(ActiveCell, firstdate).Select

Selection.Sort Key1:=Range(ActiveCell, firstdate), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("a1").Select
Exit Sub

End If
Loop
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,326
Messages
6,124,263
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top