Sort by Date

sir drinks alot

New Member
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

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
You can sort up to three levels. So have column D as your first sort level, and column C as your second.

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!

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.

That is what my suggestion will do. Did you try it?

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.

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.

ok, thanks for all your help.
i'll keep trying

Replies
19
Views
499
Replies
8
Views
135
Replies
2
Views
114
Replies
7
Views
243
Replies
1
Views
81

1,217,388
Messages
6,136,298
Members
450,002
Latest member
bybynhoc

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?

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

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