+ Reply to Thread
Results 1 to 11 of 11

Deleting rows with specific data

  1. #1
    Registered User
    Join Date
    04-25-2013
    Location
    Washington
    MS-Off Ver
    Excel 2007
    Posts
    11

    Deleting rows with specific data

    Hello! I have several hundred lines of data on one worksheet, where I'm looking for "IMP" in column A and deleting the row with "IMP" in it. The word "IMP" can appear on any row within the column. I have two issues that I can't figure out. The first is, how do I select column A without setting a range of rows? The second is, when this code runs I receive an error "Type mismatch" after the last "IMP" line is deleted.

    Thanks in advance!

    Book2.xlsm
    Please Login or Register  to view this content.

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,082

    Re: Deleting rows with specific data

    Try this code. It will automatically adjust for the number of cells in A that have data.
    Please Login or Register  to view this content.
    Last edited by Mumps1; 08-13-2013 at 01:30 PM.

  3. #3
    Registered User
    Join Date
    04-25-2013
    Location
    Washington
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Deleting rows with specific data

    Thanks Mumps1! But I get a "Type Mismatch" error for "If Cells(x,"A") = "IMP" Then"

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Deleting rows with specific data

    Another option:

    Please Login or Register  to view this content.

  5. #5
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,082

    Re: Deleting rows with specific data

    Sorry, JerBear. I noticed the sam thing and corrected the code. Try:
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    04-25-2013
    Location
    Washington
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Deleting rows with specific data

    Mumps1 - with the updated code, any lines below "IMP" get deleted as well.

    John - I get an error: "Object doesn't support this property or method" for line "Activesheet.UsedRange.AutoFilterMode = False."

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Deleting rows with specific data

    Quote Originally Posted by JerBear View Post
    Mumps1 - with the updated code, any lines below "IMP" get deleted as well.

    John - I get an error: "Object doesn't support this property or method" for line "Activesheet.UsedRange.AutoFilterMode = False."
    Oops

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    04-25-2013
    Location
    Washington
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Deleting rows with specific data

    JHD - interesting concept - I never thought to use the Filter! Thank you - your code worked just fine. I appreciate your time to help me!

  9. #9
    Registered User
    Join Date
    04-25-2013
    Location
    Washington
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Deleting rows with specific data

    Mumps1 - Thank you for your time - I can use the code you provided in another part of my workbook!

  10. #10
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,082

    Re: Deleting rows with specific data

    I'm glad everything worked out.

  11. #11
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Deleting rows with specific data

    You're welcome. Glad to help out and thanks for the feedback.

+ 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. Macro for Deleting Specific Rows of Data
    By maliotta in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-11-2013, 04:16 PM
  2. Deleting rows if specific cell is blank or have specific text
    By JoaoFerreira1985 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-11-2013, 01:18 PM
  3. [SOLVED] VBA code for deleting Rows that contain specific criteria from Filtered Data
    By carlosriver24 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-31-2012, 12:23 PM
  4. Deleting Rows Based on Specific Data
    By Jakz34 in forum Excel General
    Replies: 1
    Last Post: 04-12-2011, 09:00 PM
  5. Deleting rows based on data in a specific cell
    By minimimerr in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-15-2010, 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