converting dates csv file

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

TrustPilot

starstarstarstarstar Excellent

  • Home
  • Courses
  • Promotions
  • Schedule
  • Formats
  • Our Clients

Forum home » Delegate support and help forum » Microsoft Excel Training and help » Converting Dates in a CSV file for Stephen | Excel forum

Converting Dates in a CSV file for Stephen | Excel forum

resolvedResolved · High Priority · Version 2007

Fiona has attended:
Excel Advanced course

Converting Dates in a CSV file for Stephen

Hi,
We were trying to convert text into dates and dates from the US format into UK format (date from and date to) Please could provide me with the code / solution to be able to apply this to all CSV reports we receive.
Many thanks for your help on this.
Fiona

RE: Converting Dates in a CSV file for Stephen

Hi Fiona

Thank you for your question

The following steps should solve your problem

With the relevant excel file open, go to the visual basic editor by pressing ALT-F11. Then click on the insert menu, select module. In the main code window (Large window on the right) copy and paste the following

Sub DateConverter()

On Error GoTo errorhandler

Dim intCol As Integer
Dim dteDate As Date
Dim strDate As String
Dim intRow As Integer
Dim intStartRow As Integer

Application.ScreenUpdating = False


intCol = CInt(InputBox("Enter Column Number"))
intStartRow = CInt(InputBox("Enter start row"))


For intRow = intStartRow To Cells(5, intCol).CurrentRegion.Rows.Count

dteDate = CDate(Cells(intRow, intCol))

Cells(intRow, intCol) = dteDate

Next intRow
Exit Sub

errorhandler:

MsgBox "Error Number " & Err.Number & vbCrLf & Err.Description

End Sub


If you then go to the developer tab and select the macro button, you will see a macro called DateConverter. When you run the macro it will ask you to specify a column and row number as a start position. (Note columns are here expressed as numbers, so C would be 3)

Hope this works, if you have any difficulkties please let me know.

Regards

Stephen

Mon 19 Oct 2009: Automatically marked as resolved.


 

Excel tip:

Freeze Rows and Columns to keep lables displayed

You can freeze rows and columns in your worksheet so they don't move.

This allows you to keep row and column labels displayed on your screen as you move through a large worksheet.

Click below and/or to the right of the cell(s) you want to freeze. (NB. Excel freezes ALL the rows above and ALL the columns to left of the selected cell)

Click on the 'Windows' menu and selct 'Freeze Panes'.

Lines appear in your worksheet. The required rows and columns are frozen and remain on your screen as you move through your worksheet.

To unfreeze rows and columns, click on 'Window' menu and select 'Unfreeze Panes'.

View all Excel hints and tips


Server loaded in 0.09 secs.