+ Reply to Thread
Results 1 to 9 of 9

remove lines if achieve sertain criteria in other columns

  1. #1
    Registered User
    Join Date
    02-22-2013
    Location
    saudi
    MS-Off Ver
    Excel 2003
    Posts
    35

    remove lines if achieve sertain criteria in other columns

    Dear All

    in attached sheet , i want to delete some rows according to below criteria :

    - check if two consecutive rows have same value in columns A,B,C ----- >>> remove the row that does not contain 2077 or 2078 in column F (keep the row that contain 2077 or 2078).
    - keep the other rows that have no duplication (like rows 3,4,5 for example.

    another question , what will be the case if i can not order the rows so that lines have duplication are not consecutive ? (means rows 2 and3 in the test sheet are not consecutive and exist in rows 2 and 11 for example) ?

    note that my sheet contains about 800k rows so it is big file already.
    Thanks for your support.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    12-22-2015
    Location
    HK
    MS-Off Ver
    2010
    Posts
    532

    Re: remove lines if achieve sertain criteria in other columns

    Try this:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by ikboy; 10-27-2016 at 04:25 AM.

  3. #3
    Registered User
    Join Date
    02-22-2013
    Location
    saudi
    MS-Off Ver
    Excel 2003
    Posts
    35

    Re: remove lines if achieve sertain criteria in other columns

    Hello Ikboy

    Thanks brother , it works very good on the sample , i run it for my sheet which contains 700k rows and it is running for more than 2 hours and seems hang.
    any possible way to enhance the code performance/speed ?

    will it work if duplicate lines are not consecutive ?

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

    Re: remove lines if achieve sertain criteria in other columns

    Try
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-22-2013
    Location
    saudi
    MS-Off Ver
    Excel 2003
    Posts
    35

    Re: remove lines if achieve sertain criteria in other columns

    Wow , Thanks alot Jindon , its amazing ..... it did the job in my sheet (700K rows ) in almost no time + even it did work if there are 3 rows and it deleted the two rows and kept only the one i want . thanks you so much

    appreciate your support to explain the code as it is too hard for me to understand how it works as i need to modify it to work for other sheets and other values (other than 2078 and 2078) , in other sheets i need to do the same for 12 and 2078 and 1233 , how can i do so , can you add comment to describe each line ... i really appreciate your support as understanding the code will help me modify it for my other uses.

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

    Re: remove lines if achieve sertain criteria in other columns

    Quote Originally Posted by is2_egypt View Post
    in other sheets i need to do the same for 12 and 2078 and 1233 , how can i do so
    Change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    + means "Or" in this case.

    It is not physically deleting the row(s), just replacing the data with the data that you want.
    Deleting many rows usually takes time.

  7. #7
    Registered User
    Join Date
    02-22-2013
    Location
    saudi
    MS-Off Ver
    Excel 2003
    Posts
    35

    Re: remove lines if achieve sertain criteria in other columns

    Thanks Jindon , appreciate your support , when you have time appreciate if you add a comment describe each line what it does...if you dont mind as this code is a little bit advanced for my VBA knowledge..thanks alot.

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

    Re: remove lines if achieve sertain criteria in other columns

    Quote Originally Posted by is2_egypt View Post
    this code is a little bit advanced for my VBA knowledge..thanks alot.
    Then I suggest you first observe how Array/Dictionary works.
    Dictionary is in Excel VB help and a lot of web site explaining Arrays.

    Without the basic knowledge of above, comments means nothing to you I'm afraid...

  9. #9
    Registered User
    Join Date
    02-22-2013
    Location
    saudi
    MS-Off Ver
    Excel 2003
    Posts
    35

    Re: remove lines if achieve sertain criteria in other columns

    i will go for it .... thanks for the advise brother. appreciate really your support.

+ 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. [SOLVED] Remove lines based on cell value (remove lines in range, not entire row)
    By Tapyr in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-27-2015, 07:31 AM
  2. inserting empty cells to achieve matching numbers across two columns
    By JanieceT in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-11-2015, 06:37 PM
  3. VBA Copy&Paste Loop under sertain conditions
    By GammaKappaTau in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-19-2015, 08:25 PM
  4. [SOLVED] Macro neede to open text files from folder and remove all the lines except specific lines
    By genetist in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 10-07-2014, 02:44 AM
  5. Schedule to count multiple lines and columns to meet two criteria
    By lsudecat04 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-28-2013, 05:41 AM
  6. Replies: 0
    Last Post: 07-07-2011, 05:04 PM
  7. Remove data based on criteria from multiple columns and rows
    By jvegastn in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-09-2009, 11:42 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