+ Reply to Thread
Results 1 to 6 of 6

Run-time error '13': Type mismatch using DatePart() function

  1. #1
    Forum Contributor
    Join Date
    08-03-2009
    Location
    Cary, NC
    MS-Off Ver
    Excel 2016
    Posts
    109

    Run-time error '13': Type mismatch using DatePart() function

    I'm running the following code:

    Please Login or Register  to view this content.
    I'm getting the error at:

    Please Login or Register  to view this content.
    The date format is 1/1/2016. TransDate is reading 1/1/2016 in this line:

    Please Login or Register  to view this content.
    SortMonth is an integer. DatePart returns an integer. Why doesn't this work?
    Last edited by bishoposiris; 02-15-2016 at 11:32 AM. Reason: Solved

  2. #2
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,343

    Re: Run-time error '13': Type mismatch using DatePart() function

    try taking the quotes away from transdate

    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor
    Join Date
    05-14-2012
    Location
    Unknown
    MS-Off Ver
    Unseen
    Posts
    429

    Re: Run-time error '13': Type mismatch using DatePart() function

    Scottiex has highlighted what looks like the issue, as Transdate is a variable but would be treated as text if it's in quotes.

    This might be a better way of loading your arrays:

    Please Login or Register  to view this content.
    And then use:
    Please Login or Register  to view this content.
    to loop through the array.

    Given that you actually have 20 items in the array, that might be a safer bet ... you actually use item 17 twice, hence you only count to 19. Or is that intentional?

  4. #4
    Forum Contributor
    Join Date
    08-03-2009
    Location
    Cary, NC
    MS-Off Ver
    Excel 2016
    Posts
    109

    Re: Run-time error '13': Type mismatch using DatePart() function

    Scottiex, that was the problem! Thank you.

  5. #5
    Forum Contributor
    Join Date
    08-03-2009
    Location
    Cary, NC
    MS-Off Ver
    Excel 2016
    Posts
    109

    Re: Run-time error '13': Type mismatch using DatePart() function

    InvisibleMan, thank you for the helpful Array tips. And for pointing out item 17. That was not intentional. Didn't know about LBound and Ubound either. That will be useful. Thank you.

  6. #6
    Valued Forum Contributor
    Join Date
    05-14-2012
    Location
    Unknown
    MS-Off Ver
    Unseen
    Posts
    429

    Re: Run-time error '13': Type mismatch using DatePart() function

    You're welcome. Thanks for the rep.

+ 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. run-time error '13' type mismatch
    By baig123 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-10-2014, 06:25 AM
  2. Run time error type mismatch 13
    By Dariusd7 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-15-2013, 05:11 PM
  3. Run-time error '13': Type mismatch
    By Sky188 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-15-2013, 03:07 PM
  4. Run-Time error '13': Type mismatch
    By Drew Watson in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-28-2010, 08:39 AM
  5. Type mismatch Run-time Error 13
    By auber in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-27-2009, 10:46 AM
  6. Run time error: Type mismatch
    By Johannekie in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-04-2008, 09:11 AM
  7. run-time error 13 type mismatch
    By godster84 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-27-2007, 11:29 PM

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