+ Reply to Thread
Results 1 to 5 of 5

Type Mismatch Error

  1. #1
    Registered User
    Join Date
    04-02-2014
    Location
    saint cloud, mn
    MS-Off Ver
    Excel 2010
    Posts
    6

    Type Mismatch Error

    Hi Everyone,
    I am currently using a code that automatically copies a row to the next blank row in Sheet 5 when a date is entered into Column 14 and then deletes the row. The only problem is that if I start typing into the wrong row and delete the text before clicking off that wrong cell, the code still runs. I have tried two different versions of the code:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Both of these codes have the problem I discussed above. In an attempt to fix it (Since I am entering a date into Column N) I changed the If statement to:

    Please Login or Register  to view this content.
    Now, if I start typing into the wrong cell and delete the text before clicking off the cell, the code does not run which is what I want. If I enter a date, the code runs correctly, but I get a "Type Mismatch Error" when it is completed. The debugger shows that the error is in the statement that I changed. I can't seem to figure out why this is happening, and I'm about to start banging my head against the wall. I wouldn't even worry about this, except that I am not the one that will be entering data into the sheet. If the person using the spreadsheet makes a mistake, they won't know how to fix it.

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Type Mismatch Error

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    04-02-2014
    Location
    saint cloud, mn
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Type Mismatch Error

    Thank you! That works perfectly. Can you tell my why the value has to be a separate If statement?

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Type Mismatch Error

    It doesn't. I just prefer it that way. The issue you were having was the Target.Value > 0 line. That is what was causing the mismatch. By having it within the same if statement everytime there is a worksheet change event you test it against every parameter within that if statement. So if you make a change to B4 it tests to see if the column is 14 and if B14 value > 0, hence the possible for mismatch. (Note: Target.Value > 0 and Target.Value > "0" are completely different)

    When using worksheet change I find it best specify the range test first (to ignore all unwanted change events) then any other tests later.

  5. #5
    Registered User
    Join Date
    04-02-2014
    Location
    saint cloud, mn
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Type Mismatch Error

    I understand. Thanks again!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Run Type error 13 Type Mismatch
    By Affan Khan in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 11-13-2012, 12:58 PM
  2. [SOLVED] Run-type error 13 type mismatch
    By misop in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-05-2012, 04:08 AM
  3. Complile Error: Type Mismatch ??? After adding error trap
    By clemsoncooz in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-22-2012, 03:50 PM
  4. Conditional Formatting - Run Time Error '13' Type Mismatch Error
    By ksp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-17-2011, 07:37 PM
  5. [SOLVED] Help: Compile error: type mismatch: array or user defined type expected
    By lvcha.gouqizi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2005, 05:05 PM

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