+ Reply to Thread
Results 1 to 5 of 5

Delete rows based on search with empty cells in between groupings

  1. #1
    Registered User
    Join Date
    03-29-2013
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2010
    Posts
    16

    Delete rows based on search with empty cells in between groupings

    In the working steps of my calculations I have ended up with a list which has been spread out with several empty rows in between groups of entries. Each entry needs to stand along from the rest, and they will later get condensed back together by deleting the empty rows. However at the point I am at, I need a macro which will treat each cluster sepeartely from each other and do a search to see if all of the values in column S are the same for that cluster (they are dates). What I need is if all of the values of S for that cluster are the same, then the rows that contain that data are deleted and the macro skips down the empty cells to the next cluster and repeats.


    To put it another way, I need a macro that will look at column S, starting at S2, and search each group of rows with data as a range and search to see if they are all repeats. If so, the macro will delete these rows and skip down the empty cells in row S to the next rows with data, select that range, and search/delete again. It is important that the macro only looks at each group instead of the entire column because it is possible and allowed for the different groups to have the same data as the other groups, just not within the independent group itself.

    Any help here will be really appreciated, I am nearly at the end of a long project in developing this tool for my boss and this is the last macro that I can not figure out how to write.

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Delete rows based on search with empty cells in between groupings

    Try:

    Please Login or Register  to view this content.

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Delete rows based on search with empty cells in between groupings

    If this doesn't work, need to see your data in col.S.
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    03-29-2013
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Delete rows based on search with empty cells in between groupings

    stnkynts, I wasn't able to get this to work because the lines "Dim LR As Long, strRow As Long, miniLR As Long, sCell As Long, FinalRow As Long" and "ws.Range("S" & sCell).EntireRow.Delete Shift:=xlUp" came back with an error.

  5. #5
    Registered User
    Join Date
    03-29-2013
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Delete rows based on search with empty cells in between groupings

    jindon, this worked fantastically. Thank you very much.

+ 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