Date Format Conversion Question

Rosstamon

Board Regular
Joined
Sep 12, 2007
Messages
77
I regularly download a .csv file which I open in Excel and then save as 97-2004 workbook (.xls). Contained in this .csv file is a column with dates which are formatted as short dates. I can't seem to find a way to convert these to long dates other than changing the format and then manually retyping each date, perhaps there is one more step I'm unaware of that will accomplish this. Can someone help me out? Would very much appreciate it.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Here is a VBA solution for you

VBA Code:
Option Explicit

Sub Dates()
    Dim i As Long, lr As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row
    'change the above line to your column holding the dates and each line below 
    For i = 1 To lr
        Range("A" & i) = CDate(Range("A" & i))
        Range("A" & i) = Format(Range("A" & i), "Long Date")
    Next i
End Sub
 
Upvote 0
Here is a VBA solution for you

VBA Code:
Option Explicit

Sub Dates()
    Dim i As Long, lr As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row
    'change the above line to your column holding the dates and each line below
    For i = 1 To lr
        Range("A" & i) = CDate(Range("A" & i))
        Range("A" & i) = Format(Range("A" & i), "Long Date")
    Next i
End Sub


Thank you Alan, unfortunately I'm not familiar with how to do VBA stuff. I realize I should learn, but every time I try I usually give up and just continue to do things the hard way. How difficult would it be for me to learn this?
 
Upvote 0
Standard Module
How to install your new code
Copy the Excel VBA code
Select the workbook in which you want to store the Excel VBA code
Press Alt+F11 to open the Visual Basic Editor
Choose Insert > Module
Edit > Paste the macro into the module that appeared
Close the VBEditor
Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

To run the Excel VBA code:
Press Alt-F8 to open the macro list
Select a macro in the list
Click the Run button

Here is a link to tutorials Learn Excel VBA - Google Search
 
Upvote 0

Forum statistics

Threads
1,223,927
Messages
6,175,441
Members
452,641
Latest member
Arcaila

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