Convert text to date and time

Bijaz

New Member
Joined
Jan 23, 2011
Messages
38
Hi there,

I have a string of text with the following date/time format"
01/01/11 10:05.
How would I create a macro in which I could simply convert several hundred cells at once to an excel date time format?

Thanks!
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Copy an empty cell.

Select the cells that need to be converted from Text to Date/Time.

Format them as dd/mm/yy hh:mm

PasteSpecial>Value>Add


If you need a macro, use the macro recorder to record the above steps.
 
Upvote 0
You don't need a macro to do that.... select your cells, click "Data/Text To Columns" of XL2003 or earlier or "Data/Data Tools/Text To Columns" on the Ribbon for XL2007 (sorry, don't have XL2010, so I'm not sure where it is there), then click the Finish button on the dialog box that appears.
 
Upvote 0
To follow up on my previous post though, if you do want to do this in a macro, simply create a range reference to your cells and do like this example...

Sub FixTimes()
Range("B2:B1000").TextToColumns Space:=False
End Sub
 
Upvote 0
Rick,
Using text to column worked, but I couldn't create a macro that worked. I went through all the steps by selecting thte data d recording it, but it wouldn't work on other columns of data. Any ideas about what I'm doing wrong?
 
Upvote 0
I would have thought the macro I posted would have worked for you then as long as you changed the range from the example B2:B1000 to whatever range you actually wanted. Here, try this variation... select the column of cells that you want convert and then run this macro...

Code:
Sub FixTimes()
    Selection.TextToColumns Space:=False
End Sub

I didn't test it, but it should work. Let me know.
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,261
Members
452,901
Latest member
LisaGo

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