+ Reply to Thread
Results 1 to 5 of 5

Search column for value that's not zero, and delete rows except before and after value.

  1. #1
    Registered User
    Join Date
    03-31-2014
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    40

    Post Search column for value that's not zero, and delete rows except before and after value.

    This one I'm having a hard time figuring out....and explaining. It will be easier to understand if you first look at the attached picture.

    Example.jpg

    I want to search the H column for values that are not zero and basically select everything else except 1 row before and after each value that isn't zero, then delete the other rows. I basically want to create a bit of a buffer between the non-zero numbers. It is a bit tricky because as you can see in the picture there can be two value in the H column one after the other. There will never be more than 2 values in a row in the H column. I have 270,000 rows across multiple tabs to go through, so getting this to work would be nice.

    Thanks to anyone in advance for lending a hand!

  2. #2
    Registered User
    Join Date
    03-31-2014
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Search column for value that's not zero, and delete rows except before and after value

    I know it's not exactly the easiest thing to do, but does anyone have an idea of how to do this?

  3. #3
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,962

    Re: Search column for value that's not zero, and delete rows except before and after value

    Run this macro, which will work on whatever sheet is active - you can also loop for all the sheets if you want to, left as your homework

    Please Login or Register  to view this content.
    Last edited by Bernie Deitrick; 02-09-2015 at 04:01 PM.
    Bernie Deitrick
    Excel MVP 2000-2010

  4. #4
    Registered User
    Join Date
    03-31-2014
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Search column for value that's not zero, and delete rows except before and after value

    That works like a charm Bernie. Thank you for taking the time to figure that one out for me. You got some serious skill there. It will help save hours of time.

    Thanks again!

  5. #5
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,962

    Re: Search column for value that's not zero, and delete rows except before and after value

    It will help save hours of time.
    That's why I love macros!

+ 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. Loop to search specific names in column and delete other rows
    By EJ_2013 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-05-2013, 01:28 PM
  2. [SOLVED] VBA to search and delete rows
    By MDEN in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-03-2012, 07:46 AM
  3. Search column bottom up then delete rows based on value found
    By jaslake in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-08-2009, 10:24 AM
  4. search and delete rows
    By matvoz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-19-2008, 12:27 AM
  5. Sort Column, Delete Rows, Delete Column, Move Molumn, more inside?
    By motown in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-13-2008, 09:44 AM

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