+ Reply to Thread
Results 1 to 7 of 7

Thread: delete rows with date condition

  1. #1
    Registered User
    Join Date
    09-01-2009
    Location
    leban
    MS-Off Ver
    Excel 2003
    Posts
    3

    delete rows with date condition

    see attachment file for more understand

    i have 6 columns first one reference #
    4th and 5th columns are date
    4th date represent date that client must pay the bill
    5th date represent date that client paid the bill maybe will be before or after 4th date

    my need
    if difference of E column date vs D column date more than 7 day sow this client take more time to pay his bill, sow delete his record

    note : first column is reference number of client sow we must group it by reference number and
    delete it even one time the condition was true

    thanks
    Attached Files Attached Files
    Last edited by hagop_b; 09-02-2009 at 04:33 PM.

  2. #2
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,224

    Re: delete rows with date condition

    Just to clarify, you want rows where column E is more than 7 days LATER than column D to be deleted. Many are more than 7 days earlier. You only want ones that are late?
    _________________
    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 Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,224

    Re: delete rows with date condition

    Since this isn't the programming forum, I imagine you want the steps to do it with worksheet function. Easy enough.

    1) In G1, type "Key"
    2) in G2 enter the formula =(E2-D2)>7
    3) Double-click the lower-right corner of G2 to autocopy that formula down the entire dataset.

    You now have TRUE/FALSE all the way down. TRUE are the rows you want to delete

    4) Click cell G1
    5) Click on Data > Filter > Autofilter
    6) Select the G1 drop box and select TRUE
    7) Highlight all the visible rows
    8) Click on Edit > Delete Row
    9) Click on Data > Filter > Autofilter to turn it off
    _________________
    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!)

  4. #4
    Registered User
    Join Date
    09-01-2009
    Location
    leban
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: delete rows with date condition

    thanks for reply 50% is solved i will try to solve last 50% with understanding what u do with tools u use or any additional help i will appreciate

    now after true false all rows before delete we must group by reference column or by account with account grouping more acceptable and see if number of trues > half of false rows number this client is not good payer sow delete his all rows even that he have false rows also

    thanks really for your effort
    Last edited by hagop_b; 09-02-2009 at 01:46 AM. Reason: i write with lot mistake

  5. #5
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,224

    Re: delete rows with date condition

    Try this different formula in G2 then copied down:

    =IF((COUNTIF(B:B, B2) / 2) < SUMPRODUCT(--($B$2:$B$100=B2),--($E$2:$E$100-$D$2:$D$100>7)), "Delete", "Keep")

    Then use the Autofilter to show "Delete" rows, delete them all.

    NOTE: None of the entries in your sample workbook show as delete. To verify it worked, I changed the dates in E50:E53 by adding a year and the entire set of 4158524566 rows switched to "Delete".

    If exactly half of the entries are >7 days, it will stay "Keep". They have to be more than half as per your original wording.
    _________________
    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!)

  6. #6
    Registered User
    Join Date
    09-01-2009
    Location
    leban
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: delete rows with date condition

    can i say now 99% of problem solved and for 1% i really tried hard to copy and paste ,but wait ,,, before i paste the formula i read more about sumproduct its wow function

    thanks jbeaucaire for your time

  7. #7
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,224

    Re: delete rows with date condition

    _________________
    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!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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.2.0