+ Reply to Thread
Results 1 to 11 of 11

type mismatch '13' after deleting field with DEL button

  1. #1
    Registered User
    Join Date
    10-06-2011
    Location
    Cracow
    MS-Off Ver
    Excel 2007
    Posts
    5

    type mismatch '13' after deleting field with DEL button

    Hi,
    I got a problem, which I can't solve since 3 weeks. I've already read a lot of forums about this error, and basically I know how to deal with it, but I wrote an application with over 15000 lines (VBA) and still can't solve this issue.

    And the problem is, that I want to calculate a sum of few particular fields. So if entered a loop goes thru those fields and checkes if those are digits

    Please Login or Register  to view this content.
    I know what to do, if there are no digits or/and the cell is empty. It works OK if I clear the field value with BACKSPACE and press ENTER. But when I want to clear the field with DEL button on the keyboard I get the TYPE MISMATCH '13' error (and debugger stops at the line shown above). Even If I stop checking this value, application stops at the line, where I want assign the value to the variable:


    Please Login or Register  to view this content.
    price_is defined as Public variable As Integer


    whatever I try:
    ...... Cint(target), isNull(target), isEmpty(target) or much more it doesn't help.
    I'm desperated to finish my app, but without this I have to tell to others not to touch the DEL button, what is ridiculous.

    PLEASE, help.

    Greetings,
    Mike
    Last edited by garbage; 10-09-2011 at 06:44 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: type mismatch '13' after deleting field with DEL button

    1) Edit your post above to add code tags around the code, like so:
    Please Login or Register  to view this content.
    2) Restructure your function to test the value....
    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
    10-06-2011
    Location
    Cracow
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: type mismatch '13' after deleting field with DEL button

    Hello,
    I tried above code - now my example code is:

    Please Login or Register  to view this content.
    after I move with arrows to the field ("Q84") and press DELETE on the keyboard, I got the "RUN-TIME error '13': Type mismatch", and the debugger stops at

    Please Login or Register  to view this content.
    I don't have any idea about what may cause the problem.

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: type mismatch '13' after deleting field with DEL button

    Change the code to:
    Please Login or Register  to view this content.
    and tell us what the message says.
    Remember what the dormouse said
    Feed your head

  5. #5
    Registered User
    Join Date
    10-06-2011
    Location
    Cracow
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: type mismatch '13' after deleting field with DEL button

    one step forward .....

    If I enter some work it returns "STRING", if some number value: "Double". If I clear field with BACKSPACE it returns "Empty". If this damn DELETE button I got: "Variant()".
    I have no idea how to handle with this except for checking if typename is Variant().

    Please Login or Register  to view this content.
    is it OK or there is something else, more elegant and professional I could do?

    romperstomper: THANK YOU for a hint.

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: type mismatch '13' after deleting field with DEL button

    You've got merged cells there, haven't you?

  7. #7
    Registered User
    Join Date
    10-06-2011
    Location
    Cracow
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: type mismatch '13' after deleting field with DEL button

    Quote Originally Posted by romperstomper View Post
    You've got merged cells there, haven't you?
    Yhm .....That's true - three of them. How do you know that?

    And I need help. I tried to check the type of the cell, then fill it with some data hoping that type is going to change, but there is still Variable() and program goes into endless loop and crashes. I checked for typename and every time (whatever I put into target, or "string" or "0" or "" or just 0 (zero) the typename is always Variant()):

    Please Login or Register  to view this content.
    I really need help :-)

  8. #8
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: type mismatch '13' after deleting field with DEL button

    Try changing the original code to use:
    Please Login or Register  to view this content.
    so that it only refers to the first of the merged cells.

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

    Re: type mismatch '13' after deleting field with DEL button

    ...and this is only the first of many griefs introduced by merging cells and not telling anyone.

  10. #10
    Registered User
    Join Date
    10-06-2011
    Location
    Cracow
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: type mismatch '13' after deleting field with DEL button

    Hi once again.
    I couldn't test it right after I read this last post, but I just wanted to thank once again to romperstomper. This solution solved all of my problems in my app.

    If I'll have ever any additional problem, I'll mention about merged cells and any other activities done in the sheet

  11. #11
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: type mismatch '13' after deleting field with DEL button

    Hi,

    Better still avoid merged cells altogether. They just cause problems.
    If you're using them for formatting reasons then a much tidier solution is to use the Format cells horizontal 'center across selection' option.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

+ Reply to 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