ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   sorting on a date field (https://www.excelbanter.com/excel-worksheet-functions/114180-sorting-date-field.html)

Bob Matthews

sorting on a date field
 
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



Gary L Brown

sorting on a date field
 
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,
--
Gary Brown

If this post was helpful, please click the ''Yes'' button next to ''Was this
Post Helpfull to you?''.


"Bob Matthews" wrote:

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




Gary L Brown

sorting on a date field
 
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,
--
Gary Brown

If this post was helpful, please click the ''Yes'' button next to ''Was this
Post Helpfull to you?''.


"Bob Matthews" wrote:

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





All times are GMT +1. The time now is 11:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com