+ Reply to Thread
Results 1 to 2 of 2

Type Mismatch Trying to Delete Rows

  1. #1
    Registered User
    Join Date
    01-12-2011
    Location
    Michigan, USA
    MS-Off Ver
    2010
    Posts
    16

    Type Mismatch Trying to Delete Rows

    I have a macro that I've been using in order to clean up these text reports I receive from our ancient distribution management system. This macro has worked perfectly except for this customer, because their name has the correct amount of characters to throw a wrench into my code. The columns are separated in such a way that "- INDUS" is in its own cell, and Excel thinks this is a formula since it starts with the 'minus' symbol. This shows up as "#NAME?" in the cells where this is present (all in Column C), and gives me a type mismatch error 13 whenever I run the macro.

    I have included the code parts that may need troubleshooting below. Perhaps a formatting change would do the trick in the Text To Columns portion (I haven't yet found a working method). Note, however, that the columns must be in their current positions, or the other data will not be properly sorted. Or maybe some sort of error handling code needs to be included where the columns are deleted. Either way, I am unsure of the fix, and would greatly appreciate any help.

    Code for my text to columns:
    Please Login or Register  to view this content.
    Code to Delete Rows:
    Please Login or Register  to view this content.
    I have also attached a spreadsheet that illustrates the before and after on the trouble-causing row of text to columns.


    Edit: Looks like I solved my own problem (why would I not have thought to do this?), as if I just use On Error Resume Next before the code, then the macro finishes properly. I'm not quite sure if this is the ideal solution though, so if anyone has anything better please let me know. Otherwise I will consider this solved.
    Attached Files Attached Files
    Last edited by sweetnumb; 05-04-2011 at 02:53 PM. Reason: solved my own issue

  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 Trying to Delete Rows

    Deleting rows one at a time can be very inefficient, especially on larger datasets.

    Based on the criteria I see you are using, I would suggest you consider using the AutoFilter. IN Excel 2007 I believe it's found under Data > Table.

    Anyway, you should be able to apply a custom filter to column E testing for both "" and "OLD PRICE", then delete all visible rows, then filter column C for blanks and delete all visible rows and you're done, even if the dataset was huge, this would be very quick.

    It appears you may not have a "title row" at the top of your data, which would be necessary to use an AutoFilter, easy to add and then remove


    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!)

+ 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