+ Reply to Thread
Results 1 to 4 of 4

Run-time error '13': Type mismatch

  1. #1
    Registered User
    Join Date
    02-20-2012
    Location
    Chicago, Illinois
    MS-Off Ver
    Excel 2010
    Posts
    25

    Question Run-time error '13': Type mismatch

    ... or, "How 2 gracefully handle cell with formula error?"

    I'm an experienced scripter, but still new to Excel VBA. I appreciate everyone's patience and help!

    I have some "checker" (validation) code that loops through some rows of a worksheet, reads the value of a particular cell in each row as a string, examines it, looking for incorrect values based on some rules I've coded. It was quite an accomplishment to get that working! We were quite pleased with the early results. However, when I did some testing with some real-world data my code may run into, it crapped out when a cell's formula had an error ("#N/A").

    I want to handle this scenario gracefully in my code. I do NOT want to skip the row and continue the loop using "On Error Resume Next". I want to determine the row contains a forumla error, post a message in a different cell in the current row, then carry on with the loop.

    Can someone point me in the right direction? I am new to Excel VBA, so if I'm doing something fundamentally wrong and should take a different approach, by all means, say so. Or (hopefully), if I'm on the right track, and just need to add a few lines of code to deal with this error, let me know! I've included the code below.

    Thanks in advance!


    Please Login or Register  to view this content.
    Last edited by btmtdk; 02-26-2012 at 05:33 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

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

    You can do a simple ISERROR test on the current cell being evaluated:

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    02-20-2012
    Location
    Chicago, Illinois
    MS-Off Ver
    Excel 2010
    Posts
    25

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

    Perfect! That did the trick!

    Thank you Jerry!

    This forum is a life-saver!

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

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

    Have a look at 'specialcells' in the VBEditor's helpfiles.



+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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