+ Reply to Thread
Results 1 to 11 of 11

Run-time error '13': Type mismatch

  1. #1
    Registered User
    Join Date
    11-01-2021
    Location
    TX, USA
    MS-Off Ver
    365 Version 2109
    Posts
    6

    Run-time error '13': Type mismatch

    I apologize. I am not able to upload the sample file, post a link, or post an image, and can't figure out how to delete this post.

    I am a novice at creating macros and this one is not mine. I need some help figuring out what is casing the type mismatch error. Run the StartMacro script, uncheck the bottom box, then click the Run button to reproduce the error. Thanks so much for your help!

    EXCEL_WDFNt9OMq4.png

    Link to file: https://tinyurl.com/3ww294vd Moderator's note: I tried to attach this as a zip and also xlsb and the board gave me an error on both.
    Last edited by 6StringJazzer; 08-21-2023 at 06:37 PM. Reason: added file link

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2405
    Posts
    25,038

    Re: Run-time error '13': Type mismatch

    New members cannot post live links. Members cannot delete posts.

    Anyone can attach an image or a file.

    The yellow banner at the top of the page explains how to attach a file. If you still have trouble after trying that then PM me and I'll help.

    To attach an image, first click Go Advanced under your edit box. Then click in the text to set the cursor to where you want the image to appear, then press the image icon and attach your image.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2405
    Posts
    25,038

    Re: Run-time error '13': Type mismatch

    I will take a look at the file at the link you sent me, but meantime you should be typing all your variables. anArray and searchStr are untyped, and from the snippet here we can't see what data is being passed in through those arguments.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2405
    Posts
    25,038

    Re: Run-time error '13': Type mismatch

    When you get this error, open the Immediate window and type

    ?typename(anArray(i, 1))

    and then

    ?typename(searchStr)

    If the results to either one of these is not String, that is what your problem is. You declared each of these as Variant so the caller can pass in a value of any data type. That is not a good programming practice.

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2407 (Windows 11 23H2 64-bit)
    Posts
    83,555

    Re: Run-time error '13': Type mismatch

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not told us about this. You are required to do so.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important: https://excelguru.ca/a-message-to-forum-cross-posters/

    (Note: this requirement is not optional. As you are new here, I shall do it for you this time: https://www.mrexcel.com/board/thread...match.1243615/)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  6. #6
    Registered User
    Join Date
    12-22-2022
    Location
    California
    MS-Off Ver
    2016
    Posts
    21

    Re: Run-time error '13': Type mismatch

    Hi,

    Here's what I found on the internet, an article to fix your error.

    Best Regards.

  7. #7
    Registered User
    Join Date
    11-01-2021
    Location
    TX, USA
    MS-Off Ver
    365 Version 2109
    Posts
    6

    Re: Run-time error '13': Type mismatch

    Thank you for your response, Ali.

  8. #8
    Registered User
    Join Date
    11-01-2021
    Location
    TX, USA
    MS-Off Ver
    365 Version 2109
    Posts
    6

    Re: Run-time error '13': Type mismatch

    Thank you, Chris!

  9. #9
    Registered User
    Join Date
    11-01-2021
    Location
    TX, USA
    MS-Off Ver
    365 Version 2109
    Posts
    6

    Re: Run-time error '13': Type mismatch

    Thanks so much for your help!


    Quote Originally Posted by 6StringJazzer View Post
    When you get this error, open the Immediate window and type

    ?typename(anArray(i, 1))

    and then

    ?typename(searchStr)

    If the results to either one of these is not String, that is what your problem is. You declared each of these as Variant so the caller can pass in a value of any data type. That is not a good programming practice.

  10. #10
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2405
    Posts
    25,038

    Re: Run-time error '13': Type mismatch

    Still looking for the steps to reproduce the error in your file.

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2407 (Windows 11 23H2 64-bit)
    Posts
    83,555

    Re: Run-time error '13': Type mismatch

    Quote Originally Posted by oarsout View Post
    Thank you for your response, Ali.
    I have responded to your PM complaining about being "scolded" for cross-posting. In my response I have pointed out that the message above merely explains the rule we have and why it is in place. It is polite and to the point, NOT unfriendly as you suggest, and is a stock message used by the moderation team here.

    We have rules here that apply to ALL members and the moderation team is required to deal with anyone who fails to follow them. The requirement is that we deal with the issue in the thread in question, not privately.

    I am sorry that you feel offended, but you have not been scolded by any stretch of the imagination, and I am merely doing my job (and doing it politely).

    Please do review the forum rules before posting here again so that neither I nor anyone else on the moderation team has to remind you of them in future.

    Thank you.
    Last edited by AliGW; 08-22-2023 at 10:12 AM.

+ 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] type mismatch run time error 13
    By Sandy2385 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-25-2019, 12:56 PM
  2. [SOLVED] Getting run-time error 13 type mismatch
    By mso3 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-29-2017, 11:44 AM
  3. [SOLVED] Run-time Error '13' - Type mismatch
    By elmowax in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-21-2014, 08:03 PM
  4. Run-Time Error '13: Type Mismatch
    By mlegge77 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-18-2013, 04:44 PM
  5. Run-time error 13: Type mismatch
    By gregg141 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-02-2012, 05:22 PM
  6. [SOLVED] Run-time error '13': Type mismatch
    By btmtdk in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-26-2012, 06:32 PM
  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

Tags for this Thread

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