+ Reply to Thread
Results 1 to 10 of 10

Error 13 - Type Mismatch - Macro to delete lines

  1. #1
    Registered User
    Join Date
    08-29-2013
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    34

    Error 13 - Type Mismatch - Macro to delete lines

    Hello everyone,

    I´m getting the error message of the title "Error 13 - Type Mismatch" at the first line of the loop.

    Please Login or Register  to view this content.
    Someone knows what it could be?

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Error 13 - Type Mismatch - Macro to delete lines

    Range(Cells(1,50), Cells(1,52)).Value is an array. = does not accept an array as one of its arguments.

    As written it looks like you want the row deleted if all three cells ="" or if all three cells =0.
    Do you want the cell deleted if one of the three =0 and the other two =""?
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Registered User
    Join Date
    08-29-2013
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: Error 13 - Type Mismatch - Macro to delete lines

    As written it looks like you want the row deleted if all three cells ="" or if all three cells =0.
    Precisely what I want. Tnx.

  4. #4
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Error 13 - Type Mismatch - Macro to delete lines

    I think there might be a flaw with your logic. But anyway, your code can be changed to

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-29-2013
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: Error 13 - Type Mismatch - Macro to delete lines

    I made the "dumb" way (writing cell per cell) and it worked now. Tnx

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Error 13 - Type Mismatch - Macro to delete lines

    Try this. Note that when deleting, one should go from the bottom up.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-29-2013
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: Error 13 - Type Mismatch - Macro to delete lines

    Note that when deleting, one should go from the bottom up.
    Tnk u friend, but why that?

  8. #8
    Registered User
    Join Date
    08-29-2013
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    34

    Re: Error 13 - Type Mismatch - Macro to delete lines

    I got it now... tnx

  9. #9
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Error 13 - Type Mismatch - Macro to delete lines

    Quote Originally Posted by Marceltcm View Post
    Tnk u friend, but why that?
    Consider the data
    Adam
    Adam
    Betty
    Adam
    Please Login or Register  to view this content.
    When i = 1, it sees "Adam" and deletes Row(1), making the data
    Adam
    Betty
    Adam
    and then goes on to i=2
    Row(2) = "Betty" so it doesn't delete.
    Row(3) gets deleted
    Row(4) = "" and isn't deleted, leaving the data
    Adam
    Betty

    It missed an "Adam" because it worked top to bottom.

  10. #10
    Registered User
    Join Date
    09-11-2013
    Location
    Pittsburgh, Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    4

    Thumbs up Re: Error 13 - Type Mismatch - Macro to delete lines

    Great tip. Thanks.

+ 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. Getting Type Mismatch, Runtime Error 13 With This Macro
    By HowdeeDoodee in forum Excel General
    Replies: 16
    Last Post: 11-13-2012, 07:59 AM
  2. Re: Help with a macro- 'Run-Time error '13' Type Mismatch
    By pman in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-16-2012, 03:31 PM
  3. [SOLVED] Type Mismatch Error when I highlight multiple cells and use the delete key
    By CharlieZangel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-20-2012, 02:09 PM
  4. Macro gives Run-time error '13': Type mismatch, but nothing has changed?
    By BlondOIverBlue in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-10-2010, 11:52 PM
  5. type mismatch error in Benford's law macro
    By Sody in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-24-2006, 06:10 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