+ Reply to Thread
Results 1 to 6 of 6

Delete Entire Row based on criterion

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Delete Entire Row based on criterion

    Hello everyone. I have (hopefully) a quick issue. I would like to go through or "loop" through the cells in column "L" of my worksheet. If the string "Net", occurs in a cell. I want to delete the entire row above that cell.

    Any help is appreciated.
    Last edited by AnthonyWB; 07-28-2011 at 12:38 PM.

  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: Delete Entire Row based on criterion

    1) Assuming column Z is empty, put this formula in Z2 and copy down:

    =ISNUMBER(SEARCH(L3, "Net"))

    2) Highlight column Z and turn on the Data > Filter > AutoFilter

    3) Filter column Z for TRUE

    4) Delete all visible rows

    5) Turn off the Autofilter and clear column Z


    You can record that into a macro, but it's pretty fast as it is by hand.
    _________________
    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!)

  3. #3
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Delete Entire Row based on criterion

    JB thank you. I need however to have this running in a prexisting macro. (see code below) . The spreadsheet(s) in question are made on the fly by the code. So I cannot aply your aproach.

  4. #4
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Delete Entire Row based on criterion

    JB, i would like to fit this into here;

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Delete Entire Row based on criterion

    JB,

    I found this that you had done for a previous poster

    Please Login or Register  to view this content.
    However I need to delete the row above the cell that pocesses the criterion.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Delete Entire Row based on criterion

    I would use the technique already described in post #2. That can be recorded into a macro in seconds, code you can then add to your existing macro.

+ 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