+ Reply to Thread
Results 1 to 12 of 12

Run-time error 13 (Type Mismatch)

  1. #1
    Registered User
    Join Date
    11-15-2011
    Location
    Delhi, India
    MS-Off Ver
    Excel 2010
    Posts
    74

    Run-time error 13 (Type Mismatch)

    hi,
    i am a new user of module in excel.

    When i run the following code i get the "Type mismatch" error dialogue box. It was running fine a few hours ago.

    What is amusing is that it sometimes give the "Application or object-defined" error dialogue box as well.

    What shall i do to resolve this? And, what could be causing 2 different error dialogue boxes for the same code?

    Please Login or Register  to view this content.
    Last edited by prajesh; 11-15-2011 at 05:45 AM. Reason: solved!!!

  2. #2
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Run-time error 13 (Type Mismatch)

    hello

    is this Worksheets(1) one or i
    and
    is this Worksheets(1).cells(j, k) + Worksheets(i) i or 1
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  3. #3
    Registered User
    Join Date
    11-15-2011
    Location
    Delhi, India
    MS-Off Ver
    Excel 2010
    Posts
    74

    Re: Run-time error 13 (Type Mismatch)

    hi vlady,
    thanks for such a quick response....
    what i am trying to do is add a particular cell's value from all the worksheets (in the workbook) to the particular cell of the 1st worksheet.

    so it is worksheet(1).cells(j ,k) = worksheets(1).cells(j,k) + worksheets(i).cells(j,k)

  4. #4
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Run-time error 13 (Type Mismatch)

    i think one of the worksheets contains text
    worksheet(1).cells(j ,k) = worksheets(1).cells(j,k) + worksheets(i).cells(j,k)
    maybe on worksheet 1 or in worksheet i -- that's why you get a type mismatch


    better to post a dummy file for this

  5. #5
    Registered User
    Join Date
    11-15-2011
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Run-time error 13 (Type Mismatch)

    Your error may be happening because you do not have the dim set
    for your variables

    Please Login or Register  to view this content.

  6. #6
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Run-time error 13 (Type Mismatch)

    Tried your code it works for me
    but look at sheet i i've type text and received the error. change it back to number . It's OK.

    Attached sample.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    11-15-2011
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Run-time error 13 (Type Mismatch)

    Excel will not let you sum different data types. It defaults when you try to mix apples with oranges. Do you need text in that cell or a number?

  8. #8
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Run-time error 13 (Type Mismatch)

    @Bradelybww
    That's what i'm trying to point ou to Prajesh.
    Maybe some of the data in the sheets are formatted as text that's why he receives a type mismatch message.

    but why is it that it runs even thought there is no variable declaration? Any idea.

  9. #9
    Valued Forum Contributor Miraun's Avatar
    Join Date
    04-03-2009
    Location
    New England
    MS-Off Ver
    2003, 2007, 2010, 2013
    Posts
    554

    Re: Run-time error 13 (Type Mismatch)

    If you don't define variables, they're treated as variant types, which I believe consumes a little more memory than defining them as an integer, range, etc.
    Going for Guru! Click the Star to the bottom left of this post if I helped!

  10. #10
    Registered User
    Join Date
    11-15-2011
    Location
    Delhi, India
    MS-Off Ver
    Excel 2010
    Posts
    74

    Re: Run-time error 13 (Type Mismatch)

    thanks all you guys for your suggestions...........
    and i have found a solution too.........
    my new formula that works looks like this;

    Worksheets(1).cells(j, k) = Worksheets(1).cells(j, k) + Val(Worksheets(i).cells(j + 4, k))

    just added "Val" and it worked.
    but, frankly speaking i have no idea what difference does it make.

    you guys must know it, right?

  11. #11
    Valued Forum Contributor Miraun's Avatar
    Join Date
    04-03-2009
    Location
    New England
    MS-Off Ver
    2003, 2007, 2010, 2013
    Posts
    554

    Re: Run-time error 13 (Type Mismatch)

    IThe Val function accepts a string as input and returns the numbers found in that string.

    For example:
    Val("34 10 Main Street") would return 3410

    So, if your information is formatted as Text, or contains alpha characters in the cell, it would cause the Run-time error 13 of a type mismatch, trying to add text and numbers.

  12. #12
    Registered User
    Join Date
    11-15-2011
    Location
    Delhi, India
    MS-Off Ver
    Excel 2010
    Posts
    74

    Re: Run-time error 13 (Type Mismatch)

    got it!
    thanks Miraun...

+ 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