+ Reply to Thread
Results 1 to 7 of 7

Run Time Error 13 Type Mismatch

  1. #1
    Registered User
    Join Date
    06-14-2012
    Location
    Cincinnati
    MS-Off Ver
    Excel 2007
    Posts
    13

    Run Time Error 13 Type Mismatch

    Having problems with my code. It will work by itself but when I copy and paste data into the worksheet I get a run time error 13 type mismatch.



    Please Login or Register  to view this content.
    The error is with the first case "Case Injected"


    Code using to move to the worksheet with the above code.

    Please Login or Register  to view this content.

    Any help would be greatly appreciated.

    Thanks
    Last edited by nahge123; 07-15-2012 at 12:45 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: Run Time Error 13 Type Mismatch

    Please read the forum rules and add code tags above.

    Maybe include a Case Else and check what's in the Target Cell. I seem to think that Select Case is case sensitive so perhaps use LCase on the Target.Value and around the text ... or just make the first characters of the text lower case.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    06-14-2012
    Location
    Cincinnati
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Run Time Error 13 Type Mismatch

    I'm very new to VBA and the original code that I had found had the LCase, which is where the original error was. So I removed the LCase and made all the first characters of the text lower case...... still ended up with a run time error 13, but the error was with the first case "Case Injected"


    Please Login or Register  to view this content.
    Run Time Error 13 Type Mismatch in code Select Case LCase(Target.Value)
    Attached Files Attached Files
    Last edited by nahge123; 07-15-2012 at 12:54 AM.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: Run Time Error 13 Type Mismatch

    Please, read the forum rules and add code tags to both your posts.

    Also, please post sample workbook ... no-one can do much with this without data.

    Regards, TMS

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: Run Time Error 13 Type Mismatch

    Thanks for the code tags and the sample workbook.

    The second version of the code works fine for me.

    Maybe a little shorter:

    Please Login or Register  to view this content.

    Interestingly, with the first set of code, if you type "injected", no quotes and lower case "i", the DV accepts it, the Worksheet Change event fires, but the Case Select just drops through. The second version accepts either case.

    I don't get any error messages with any of the code.

    Note that you should not have a subroutine or macro that has a reserved word for its name; in this case, Copy(). Excel/VBA can get quite confused.

    And you shouldn't really have code in the Workbook module unless they are workbook events. Your MasterModule should be in a standard module

    Regards, TMS

  6. #6
    Registered User
    Join Date
    06-14-2012
    Location
    Cincinnati
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Run Time Error 13 Type Mismatch

    TMS

    Sorry it has taken me soooo long to respond but I receive the "run time error 13 type mismatch" when I run module 4 which should copy data from "data"2 to "check list". When I hit debug it highlights "select case lcase (target.value) on sheet 1 code.

    Thank you

    ---------- Post added at 05:06 PM ---------- Previous post was at 04:59 PM ----------

    Also when I made the suggested changes to the private sub that you suggested that you posted above I now get an "compile error". Invalid or unqualified reference". And it highlights .Copy under case injected.?

    Thank

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: Run Time Error 13 Type Mismatch

    The code works fine for me just copied and pasted into the sheet class module for the check list sheet.

    So, nothing wrong with the code. Nothing wrong with the sample. Did you copy and paste the code? Did you make any changes to the code? Is the structure of your real workbook different? Not that the workbook structure would make a difference, I don't think. What can I say? You're using a drop down data validation list so you can't mistype anything ...

    You've actually confused me in that you say:
    which should copy data from "data"2 to "check list"
    There's no data in that sheet and no code behind it, at least in the sample.

    You need to provide a sample of the workbook which is more reflective of what you really have, complete with code and before and after sheets explaining what should happen, when and why.

    If you leave it three weeks before you come back, I'll be in the middle of my holiday so you're unlikely to get an answer for a month or so. Guess it's not urgent?

    Regards, TMS

+ 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