• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Make formula as an add-in

The following formual was provided to me:

=DATE(RIGHT(A1,4),LEFT(A1,LEN(MONTH(TODAY()))),MID(A1,LEN(MONTH(TODAY()))+1,LEN(A1)-LEN(MONTH(TODAY()))-4))

It takes a date and converts it from 112015 to 1/1/2015 OR a date like this 1112015 into 1/11/2015 or 11/1/2015 depending on the current date.

So, how do I make this formula an add-in so I do not have to type it or open a previous file and copy it?

Thanks,
 
You could add it to your personal workbook as a function, I suppose.

What is the Personal workbook?
http://chandoo.org/wp/2013/11/18/using-personal-macro-workbook/

Code for your UDF:
Code:
Function MyDate(DateLong As Long) As Date
MyDate = Evaluate("=DATE(RIGHT(" & DateLong & ",4),LEFT(" & DateLong & _
    ",LEN(MONTH(TODAY()))),MID(" & DateLong & ",LEN(MONTH(TODAY()))+1,LEN(" & DateLong & ")-LEN(MONTH(TODAY()))-4))")
End Function
Copy that into your Personal workbook, and now, in any workbook, you can type:
=MyDate(A1)
and it will convert the number into a date.
 
Back
Top