Sort by Date

sir drinks alot

New Member
Joined
Aug 1, 2006
Messages
37
sheet:
Book2
CDEF
2DATEACTIVE
35/8/2006A
46/9/2006
55/8/2004A
69/2/2006
74/25/2006A
84/26/2006A
94/27/2006
104/28/2006A
114/29/2006
124/30/2006A
135/1/2006A
145/2/2006A
155/3/2006
165/4/2006A
175/5/2006
185/6/2006
195/7/2006A
205/8/2006
215/9/2006A
Sheet1


how can i sort by date, ascending order, of only the active dates?

anybody got some sweet sort code or something?

thanks.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
You can sort up to three levels. So have column D as your first sort level, and column C as your second.
 
Upvote 0
First, find out how many rows you have to work with:

LastRow = shtOne.Cells(Rows.Count, "C").End(xlUp).Row

' Then set up a loop:

For i = 2 to LastRow ' start at row 2, not your header row!
if Range("D" & i).Value = "A" then ( here you need to give more
detail on what you want to do - delete the rows with inactive dates,
or do you want to copy the date and some other columns to another
sheet, and sort them there? Both easy to do)
Next i
Range("C2").Select 'this block sorts the range before copying the data
Selection.Sort Key1:=Range("C2"), Order1:=xlAscending, Header:=xlYes
(this assumes you've deleted the inactive rows, and sorts your stuff in place. If you have copied the active rows to another sheet, you'll need to tell this block what sheet you're using.)

Hope this helps!
 
Upvote 0
hey thanks for the replies.

i want to sort all the active dates to the top of the list, then all the inactive dates underneath those.
 
Upvote 0
That is what my suggestion will do. Did you try it?
 
Upvote 0
not yet, without some sort of code i don't know how to do that.
i basically want to sort the entire row, because on th real sheet there will be other columns of info.
 
Upvote 0
Are you trying to do this code (it isn't necessary to use code, unless that is one of your requirements)?

You can simply use Data | Sort ...

To get the code, just turn on the Macro Recorder and record yourself performing the steps. This will give you the code you need.
 
Upvote 0

Forum statistics

Threads
1,214,952
Messages
6,122,457
Members
449,083
Latest member
Ava19

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