Converting 6-digit number to date

litestream

Active Member
Joined
Jul 24, 2006
Messages
323
I have a worksheet with a date as a number in the format ddmmyy - i.e. 17th July 2008 would be shown as 170708.

How can I convert 170708 to 17th July 2008 using vba?
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Why do you need code?

Select the column with dates, goto Data>Text to columns... and on the 3rd step select DMY from the Column data format dropdown.

If you really need code you could record this when you do it.
 
Upvote 0
Without VBA, select the 'dates' Data > Text to Columns, click Next twice and on the third screen tick Date select DMY and click Finish.
 
Upvote 0
Code:
strTest = Range("A1").text
msgbox datevalue(left(strtest,2) & "/" & mid(strtest,3,2) & "/" & right(strtest,2))
for example.
 
Upvote 0
The 6-digit number is generated from the sheet name and is not in a cell. My worksheets are wc200708, wc270708 etc.

I removed the "wc" portion using vba but was wondering if I could convert the remaining 6-digit number to a date then show this in a cell on the worksheet.
 
Upvote 0
Here's something using DateValue and Format.
Code:
[b1] = DateValue(Format([a1], "00\/00\/00"))
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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