+ Reply to Thread
Results 1 to 3 of 3

Converting Text To Date in VBA

  1. #1
    Registered User
    Join Date
    12-15-2015
    Location
    Regina, Saskatchewan, Canada
    MS-Off Ver
    2013
    Posts
    22

    Converting Text To Date in VBA

    Good Morning,

    I am looking to convert 4 digit text numbers to a month/year format that can be filtered.

    Currently the dates will show up as 1014 for October 2014. I can not format to date, and when I use text to columns it doesn't format the entire column, about 95% will come through. Below is the code for the text to columns.

    Columns("E:E").TextToColumns Destination:=Range("E1"), DataType:=xlFixedWidth, FieldInfo:=Array(0, 5), TrailingMinusNumbers:=True

    Looking for any way to convert 100% of the dates. The other thing about the above method of converting to dates it assumes all dates are 2016 and does not work.

    Any help would b greatly appreciated.

    Thank you.
    Last edited by M7A0S8T8E5R; 10-18-2016 at 12:08 PM.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,819

    Re: Converting Text To Date in VBA

    One way is to use a formula, like this:

    =DATE(2000+RIGHT(E1,2),LEFT(E1,2),1)

    which will put each date as the 1st of the month. Format in the style you prefer, then copy down.

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    12-15-2015
    Location
    Regina, Saskatchewan, Canada
    MS-Off Ver
    2013
    Posts
    22

    Re: Converting Text To Date in VBA

    Thanks Pete!

    That worked perfectly!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Converting text Date to Excel date
    By vzw1965 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-01-2016, 09:01 AM
  2. [SOLVED] Converting Date Text to Number format to use in a VLOOKUP to polpulate data based by date
    By Rossovich in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 04-08-2015, 10:43 AM
  3. Converting Text to Date & Sorting on Date
    By andresndor in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-10-2014, 04:48 PM
  4. Converting text string that contains a date and time to a date
    By jmforde in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-12-2013, 02:31 PM
  5. Replies: 0
    Last Post: 01-30-2013, 07:05 PM
  6. [SOLVED] Converting from Text>Date Serial>Date
    By Schwartz in forum Excel General
    Replies: 17
    Last Post: 04-17-2012, 04:26 PM
  7. Converting date text to date format
    By reggie1000 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-01-2009, 06:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1