data sorting according to the date
Sub SortData()
Dim StartDate As Date
Dim EndDate As Date
Dim StartRow As Integer
Dim EndRow As Integer
Dim i As Integer
' Allocate cells in which you can specify the
' StartDate and EndDate for your filter (Assumed D1 and D2 here)
' Enter dates into your chosen cells formatted as dates.
StartDate = Range("D1").Value
EndDate = Range("D2").Value
Range("A1").Select
' Find the StartDate position
Do Until ActiveCell.Offset(i, 0).Value = StartDate
i = i + 1
Loop
StartRow = Range("A1").Offset(i, 0).Row
' Reset the counter
i=0
' Find the EndDate position
Do Until ActiveCell.Offset(i, 0).Value = EndDate
i = i + 1
Loop
EndRow = Range("A1").Offset(i, 0).Row
' Now use StartRow and EndRow to sort your data
End Sub
massi wrote:
i have column A with the dates from 1 jan 06 to 31 dec 06 and the column next
to it has some data.
how can i do a filter that can sort the data only for the range i want (ie
from 1 jan to 22 apr 06)
thanks
|