Age: Formula or vba?

lol.xls

Board Regular
Joined
Oct 5, 2009
Messages
174
I have a worksheet which calculates the amount of time an employee has been with our company. I currently use datedif, but i am unable to sort properly using this method. Is their a way to change the output using datedif from m,d,yyyy to mm,dd,yyyy? If not, anyone have a vba solution? Thanks for the help!
 
try:
=if(x3=0,(text(datedif(e3,f3,"y"),"##")&" years, "&text(datedif(e3,f3,"ym"),"##")&" months, "&text(datedif(e3,f3,"md"),"###")&" days"),(text(datedif(e3,$u$1,"y"),"##")&" years, "&text(datedif(e3,$u$1,"ym"),"##")&" months, "&text(datedif(e3,$u$1,"md"),"###")&" days"))

assumes no one works more than 99 years with your company!

Edit: Note, prefer excelestial's idea (but do we need rank() ... Just sort by number of days ? ...)

worked great. Thanks a bunch!
 
Upvote 0

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,215,061
Messages
6,122,922
Members
449,094
Latest member
teemeren

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
Back
Top