sorting on a date field

  • Thread starter Thread starter Bob Matthews
  • Start date Start date
B

Bob Matthews

I have a date field with dates ranging from the 1850s through to 1930 with
dd/mm/yyyy
I know about xdate - to handle dates before 1900

Is it possible to sort on this field successfully ?
If so, how ?

Bob M
 
Using John Walkenbach's XDate concept, use...
'/=======================================/
Public Function XDateSerial(Select_Cell As Range) As Double
Application.Volatile
On Error Resume Next
XDateSerial = DateValue(Select_Cell) * 1
End Function
'/=======================================/

Cell A1 = 10/12/1930
- Cell B1=XDateSerial(A1) = 11243
Cell A2 = 10/12/1850
- Cell B2=XDateSerial(A2) = -17976

This makes it easy to sort the date range.

HTH,
 
Using John Wlakenbach's examples...
'/===========================================================/
Public Function XDateSerial(Select_Cell As Range) As Double
Application.Volatile
On Error Resume Next
XDateSerial = DateValue(Select_Cell) * 1
End Function
'/===========================================================/

A1 = 10/15/1930
A2 = 10/15/1850

B1 = XDateSerial(A1) evaluates to 11243
B2 = XDateSerial(A2) evaluates to -17976

Now, it's easy to sort by 'date'.

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top