+ Reply to Thread
Results 1 to 12 of 12

Delete all rows for given FirstLast name where total payment sum is "negative"

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,677

    Delete all rows for given FirstLast name where total payment sum is "negative"

    Hi, I have a program that works. But i have to go through the file 3 times and for large files this may not be good. Also, i was wondering ifthere is a "better" way to approach this than what i did. So what i did (i include the code) is as follows:
    Loop1: build dictionary where the key is the firstlast-name and contents of the dictionary sum the payments value for given firstlastname.
    Loop2: adds elements to this dictionary where the sum of the payments value is negative
    Loop3: remove those rows where the firstlastname is negagive.

    not sure if there is a better way or not .....this seems to work though.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,512

    Re: Delete all rows for given FirstLast name where total payment sum is "negative"

    Please Login or Register  to view this content.
    Last edited by daboho; 05-09-2024 at 06:50 PM.
    "Presh Star Who has help you *For Add Reputation!! And mark case as Solve"

  3. #3
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,016

    Re: Delete all rows for given FirstLast name where total payment sum is "negative"

    But i have to go through the file 3 times and for large files this may not be good.
    About how many rows is your data?

  4. #4
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,085

    Re: Delete all rows for given FirstLast name where total payment sum is "negative"

    maybe

    Please Login or Register  to view this content.
    Last edited by ByteMarks; 05-09-2024 at 12:25 PM.

  5. #5
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,677

    Re: Delete all rows for given FirstLast name where total payment sum is "negative"

    daboho, i get a type mismatch error at this step
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,677

    Re: Delete all rows for given FirstLast name where total payment sum is "negative"

    akuini, i am not 100% sure of the number of rows....it can vary between 6000 and 30000

  7. #7
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,677

    Re: Delete all rows for given FirstLast name where total payment sum is "negative"

    Question:

    What does this do:
    Please Login or Register  to view this content.
    What does this do:
    Please Login or Register  to view this content.

    How does rng change value?

  8. #8
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,085

    Re: Delete all rows for given FirstLast name where total payment sum is "negative"

    I've corrected the code in post4 - it should have been looking at column C, not A

    This join the ranges rng and f
    Please Login or Register  to view this content.

    This evaluates a sumif formula which sums column D where C = C of the row the loop is currently at
    Please Login or Register  to view this content.

  9. #9
    Forum Expert Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,450

    Re: Delete all rows for given FirstLast name where total payment sum is "negative"

    Give this a go...
    Please Login or Register  to view this content.
    Come to think of it...with 30K rows...perhaps sort and clear will be faster than blank rows delete...will await feedback...
    Attached Files Attached Files
    Last edited by Sintek; 05-09-2024 at 02:26 PM.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  10. #10
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,512

    Re: Delete all rows for given FirstLast name where total payment sum is "negative"

    Should be like this, i has update code in post #2
    Please Login or Register  to view this content.

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

    Re: Delete all rows for given FirstLast name where total payment sum is "negative"

    welchs101,

    Use of Array, Dictionary & AutoFilter.
    Please Login or Register  to view this content.

  12. #12
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,512

    Re: Delete all rows for given FirstLast name where total payment sum is "negative"

    Please Login or Register  to view this content.
    Last edited by daboho; 05-10-2024 at 09:07 PM.

+ 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. Automating "combine similar rows"? "delete other rows". Many transactions.
    By Mtnsun in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-13-2024, 12:52 AM
  2. [SOLVED] If cell equals "CR" then make cell to left negative and delete "CR".......
    By pasqualebaldi in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-14-2016, 07:51 PM
  3. [SOLVED] Delete Rows if a cell does not equal "Finished" or "Complete"
    By Justair07 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 09-27-2013, 12:40 PM
  4. Delete rows in the result of formulas "OK" n column "J"
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-29-2012, 10:08 AM
  5. [SOLVED] Macro to delete entire row if cell contains the word "total" or "Total"
    By theatricalveggie in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-10-2011, 12:38 PM
  6. Delete Rows Until "Total" Found in Column A
    By Buddy7 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-29-2009, 08:05 PM
  7. Delete Rows that Contain the Text "Total" and vice versa
    By SteveC in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-25-2006, 03:15 PM

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