parsing data into workbook
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Parsing data into a workbook, date / time errors

Parsing data into a workbook, date / time errors

resolvedResolved · Low Priority · Version 2003

replyReply Thu 15 May 2008, 17:05Delegate Sarah said...

Sarah has attended:
Excel VBA Intro Intermediate course
Access VBA course

Parsing data into a workbook, date / time errors

Hi folks!

I'm designing a workbook which parses data from a comma separated (.csv) file into a new worksheet within the workbook then formats the sheet.

The code I have is mostly succesful at parsing the data, but unfortunately where I have two columns of date and time stamps eg. dd/mm/yyyy hh:mm:ss, they are copied across in US date format rather than U.K.
US date formats are mm/dd/yyyy hh:mm:ss.

The main problem with this is that the second date time stamp column may be in a different place depending on the data in the .csv file, so I can't tell the code to look in the same place and adjust the date with the DateSerial function.

How can I get the code to look at the type of data between each comma, determine it is a date, and parse it into the workbook in the correct U.K format?

Thanks for your help!


For upcoming training course dates see: Pricing & availability

replyReply Fri 16 May 2008, 11:17Delegate Sarah said...

RE: Parsing data into a workbook, date / time errors

Never mind folks, I fixed it.

For anyone stuck doing something similar, here's my solution.

Instead of trying to write code to check the dates on parsing in the data I recorded a macro using Excel's 'Import External Data' function in the 'Tools' menu.

From there it was fairly easy to specify the filename as a separate variable and modify the code to work with my project. It seems ok importing the dates without modifying them to U.S format.

If you are fortunate to know which columns will always contain dates, you can specify them in the import wizard.

If anyone is working on a similar project and would like to see the code I used, please get in touch.

 

Please browse our web site to find out more about
excel one day course london and other Microsoft training courses.

Excel tip:

Transpose text

You can transpose any range of cells, turning the columns into rows and the rows into columns. Just follow these steps:

Select the range.

Click the Copy button on the Standard toolbar to copy it to the Clipboard.

Select a cell outside of the range you copied.

Select Paste Special from the Edit menu.

In the Paste Special dialog box, click Transpose, then OK.

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard