+ Reply to Thread
Results 1 to 5 of 5

Date notation not recognized by vba

  1. #1
    Forum Contributor
    Join Date
    04-26-2017
    Location
    Brussels, Belgium
    MS-Off Ver
    2010
    Posts
    133

    Date notation not recognized by vba

    Hi,

    I have dates in a string in excel which are formatted like "dd.mm.yyyy"
    I don't manage to get VBA to recognize the date, I get the error 13 "Type mismatch" on the line ConvertToDate = CDate(x(1))

    Example: in the following code x(1) = 06.07.2020
    Please Login or Register  to view this content.
    I assume I try to make the string look like a date in the wrong way?

    Your help would be appreciated!
    Last edited by Solvax; 11-07-2020 at 06:20 PM.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Date notation not recognized by vba

    Try:=


    Please Login or Register  to view this content.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,416

    Re: Date notation not recognized by vba

    Try the red highlighted line of code this way...
    Please Login or Register  to view this content.
    Last edited by Rick Rothstein; 11-07-2020 at 08:41 PM.

  4. #4
    Forum Contributor
    Join Date
    04-26-2017
    Location
    Brussels, Belgium
    MS-Off Ver
    2010
    Posts
    133

    Re: Date notation not recognized by vba

    Thank you guys for the solutions. Both worked! Kudos to you!

  5. #5
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,416

    Re: Date notation not recognized by vba

    Just so I know for the future... I am guessing the order for your locale's dates is day month year. If so, did my method and mehmetcik's method produce the same date for you? I don't do international programming, so I am not sure, but my understanding is that VBA works with US locale date ordering (month day year) so I assumed simply replacing the dots with slashes would not produce the correct date for you. So I am asking... is your locale's date ordering day month year and, if so, did mehmetcik's suggestion give you the correct date?

+ 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] date & time not recognized in cells; need a formula.
    By countryfan_nt in forum Excel General
    Replies: 2
    Last Post: 08-23-2016, 09:42 AM
  2. date time stamp not recognized
    By hiswillbedun in forum Excel General
    Replies: 1
    Last Post: 11-19-2015, 05:41 PM
  3. Date not recognized
    By juan.doe in forum Excel General
    Replies: 5
    Last Post: 01-12-2015, 02:41 AM
  4. [SOLVED] Date not being recognized
    By warpdesign in forum Excel General
    Replies: 5
    Last Post: 12-09-2014, 02:14 PM
  5. Date format (xx/xx/xxxx) not recognized?
    By Sybil in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 08-14-2013, 01:34 PM
  6. [SOLVED] Date format not recognized
    By matt3m in forum Excel General
    Replies: 4
    Last Post: 09-06-2012, 07:59 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