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

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
58,415
Office Version
  1. 365
Platform
  1. Windows
You can sort up to three levels. So have column D as your first sort level, and column C as your second.
 

PolarBear

Board Regular
Joined
Sep 26, 2005
Messages
215
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!
 

sir drinks alot

New Member
Joined
Aug 1, 2006
Messages
37
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.
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
58,415
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

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

sir drinks alot

New Member
Joined
Aug 1, 2006
Messages
37
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.
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
58,415
Office Version
  1. 365
Platform
  1. Windows
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.
 

Forum statistics

Threads
1,137,302
Messages
5,680,710
Members
419,929
Latest member
Atlas Quinn

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
Top