Date Format Question

dariushou

Board Regular
Joined
Feb 17, 2008
Messages
126
I have the text ouput of "Jun08-Mar38" in a cell--let's say B59. I want to convert it to the format 6/08 - 3/38 using a formula or vba, but i can't figure out how to do that. There are many dates that i have that i need converting and there is no pattern to the months/years.

Thanks!!
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
This assumes month is always three letters and year is always two digits.

Code:
=TEXT(DATEVALUE(LEFT(LEFT(B59,FIND("-",B59)-1),3)&" "&RIGHT(LEFT(B59,FIND("-",B59)-1),2)),"mm/yy")&" - "&TEXT(DATEVALUE(LEFT(RIGHT(B59,LEN(B59)-FIND("-",B59)),3)&" "&RIGHT(RIGHT(B59,LEN(B59)-FIND("-",B59)),2)),"mm/yy")
 
Upvote 0
Great!! That worked perfect. Would you happen to know how i could perform the calc as a macro and then copy the result into a worksheet of another book. For example, I currently have a macro that opens up workbook "01B.xls" which is where the date resides. I would like the macro to perform your calc on cell B59 in the worksheet titled "01B PY" in the related workbook "01B.xls" and then paste the result in another workbook titled "Master.xls" in worksheet "01B" cell A1.
 
Upvote 0
The formula you gave works great when the 1st month begins in 2008. But i can't get it to work when the text is say Jun18-Mar38. The result i want is 06/18 - 03/38. The formula you gave gives, 06/08 - 03/38.

Any ideas?
 
Upvote 0
Thanks Barry. That worked perfect.

Would you happen to know how to do the following:

Perform the calc as a macro and then copy the result into a worksheet of another book. For example, I currently have a macro that opens up workbook "01B.xls" which is where the date resides. I would like the macro to perform your calc on cell B59 in the worksheet titled "01B PY" in the related workbook "01B.xls" and then paste the result in another workbook titled "Master.xls" in worksheet "01B" cell A1.
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

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