Closed Thread
Results 1 to 8 of 8

Excel VBA Frustrating Run-time error '13' Type mismatch

  1. #1
    shastamccloud
    Guest

    Excel VBA Frustrating Run-time error '13' Type mismatch

    Hi everyone,

    I'm getting frustrated as heck trying to resolve an error 13 in my Macro Code in my Excel 2007 spreadsheet. I've read all about this error and understand that it's sometimes caused by mixing strings into math equations.

    The code is: (the error is the second line)
    Please Login or Register  to view this content.
    The debugger says that the value of Retirement.Cells(17,6) is 76.692, and the value of Executive.Cells(4,14) is "". At first, I thought this error was caused by that Null value in (4,14), but this code works successfully in other spreadsheets with these values.

    Also, i guess I have a second question: If that value is Null, then how do that trigger this loop? I always assumes that Null was not considered greater than zero.

    BACKGROUND: this spreadsheet was produced as a report by an ASPX server. A spreadsheet is put on the server as a blank template, then the server fills it with data and downloads to the user.

    CROSSPOST: Hello everyone, I have crossposted this message at the following URL because I'm seeking help for a project that is due in a couple hours. If I get a response, I will post the answer at both sites and I will mark both as solved so I don't waste anybody's time or effort.


    http://www.mrexcel.com/forum/showthr...34#post2534334
    Last edited by shastamccloud; 12-06-2010 at 06:54 PM. Reason: I like

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Excel VBA Frustrating Run-time error '13' Type mismatch

    Your post does not comply with Rule 8 of our Forum RULES. Cross-posting is when you post the same question in other forums on the web. You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser)to the cross-post. Expect cross-posts without a link to be closed a message will be posted by the moderator explaining why. We are here to help so help us help you!

    Read this to understand why we ask you to do this
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    shastamccloud
    Guest

    Re: Excel VBA Frustrating Run-time error '13' Type mismatch

    URL:http://www.mrexcel.com/forum/showthr...34#post2534334

  4. #4
    shastamccloud
    Guest

    Re: Excel VBA Frustrating Run-time error '13' Type mismatch

    Hi

    Firstly I think you should explicitly qualify the property you want to work with.
    Secondly are you sure that the cell Is Null, and that it isn't being considered a string because of the import process?

    Perhaps:
    Please Login or Register  to view this content.
    Or, consider using CDbl to coerce the value in Cells(4,14) to a double.
    Last edited by shastamccloud; 12-06-2010 at 06:55 PM.

  5. #5
    shastamccloud
    Guest

    Re: Excel VBA Frustrating Run-time error '13' Type mismatch

    Use Val function to convert to numeric for the If test and it should work.
    Please Login or Register  to view this content.
    With the following code anything, other than zero or blank, will evaluate as > 0. Using Val function prevents that occuring.

    If Executive.Cells(4, 14) > 0 Then

    Caveat. Val stops reading when it encounters the first non numeric character and 23A would return 23 which is greater than zero.

    Better answer would be following to test for both numeric and convert to numeric value
    <code>
    If IsNumeric(Executive.Cells(4, 14)) And Val(Executive.Cells(4, 14)) > 0 Then
    </code>

    Note that IsNumeric will return true if a numeric value is entered as text but the Val function will then convert that to numeric for the maths operation.
    Last edited by shastamccloud; 12-06-2010 at 06:56 PM. Reason: A couple of niggers told me to

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Excel VBA Frustrating Run-time error '13' Type mismatch

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

    One warning should be enough to propt you to actually read the Forum rules that you agreed to when you joined. Each post you have made has totally ignored our rules, if you can't be bothered to read & follow the rules then don't bother posting
    Last edited by royUK; 12-06-2010 at 03:55 PM.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  7. #7
    shastamccloud
    Guest

    Re: Excel VBA Frustrating Run-time error '13' Type mismatch

    Administrator: I just want to say "**** You, Nigger" to you.

    You need to mind your own ******* business. If you've sent out 18,333 emails telling people to obey the rules, then you are one sad ****.

    I'm serious: you need to get a life. You are the most pitiful piece of **** I've ever come into contact with.

    I say it once more to you administrator: "**** you, nigger"

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Excel VBA Frustrating Run-time error '13' Type mismatch

    We don't need idiots like you here. It's not much to ask you to follow a few simple rules in return for free help

Closed Thread

Thread Information

Users Browsing this Thread

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

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