Solved

Formatting Dates Again!

Posted on 2007-03-26
1
192 Views
Last Modified: 2010-04-30
I have market data that I input into an array then copy to a worksheet.  For format of the text files is as follows:
10032005,3910,3910,3910,3910,10,3,2
1022007,3910,3910,3910,3910,10,3,2
The first column is the date in the format  mm/dd/yyyy,  But the month may be 1 or 2 chars i.e "1" not "01".

When I format my cell in excel to be a date in the form mm/dd/yyyy the input text 10032005 does not give me 10/03/2005 but 10/04/2020.  I need to use VBA to get the correct result.  But can anyone explain this?  
0
Comment
Question by:gamadmin
1 Comment
 
LVL 1

Accepted Solution

by:
mattbroomhall earned 250 total points
ID: 18794660
This formula can read both formats, where A1 is replaced with the cell you have the date in.

=DATE(RIGHT(A1,4),IF(LEN(A1)=8,RIGHT(LEFT(A1,LEN(A1)-4),2),RIGHT(LEFT(A1,LEN(A1)-4),1)),LEFT(A1,2))
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question