+ Reply to Thread
Results 1 to 22 of 22

Over 200,000 lines and need a macro to calculate matching PO valuse

  1. #1
    Registered User
    Join Date
    11-27-2012
    Location
    Asheville, NC
    MS-Off Ver
    Excel 2007
    Posts
    12

    Unhappy Over 200,000 lines and need a macro to calculate matching PO valuse

    Hi,

    I've tried an "IF statement" to solve my problem but that resulted in taking too much of the resources in our servers and taking way too long.
    My problem:

    I have over 200,000 lines of data. I have a PO number in column H which may or may not repeat in that column all the way down. I need to total the dollar amounts on that same row for each of those matching PO numbers. I haven't been able to figure out how to write the macro and I'm not sure if it will solve the problem of eating up resources. It would be great if I can have the macro total the dollars for the matching POs and if the total equals zero, delete those lines.

    Thanks for any help.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,651

    Re: Over 200,000 lines and need a macro to calculate matching PO valuse

    Can't you just use SUMIF or SUMIFS.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    11-27-2012
    Location
    Asheville, NC
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Over 200,000 lines and need a macro to calculate matching PO valuse

    That is what I did. Clogged up the server and took forever. Acted as those it wanted to calculate forever. Even if I turned of calculation and manually calculated.

  4. #4
    Registered User
    Join Date
    11-27-2012
    Location
    Asheville, NC
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Over 200,000 lines and need a macro to calculate matching PO valuse

    I can spell, sorry... Acted as though, turned off the calculation

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,651

    Re: Over 200,000 lines and need a macro to calculate matching PO valuse

    Can you post a sample? Obviously, not the full 200,000 lines

    Or maybe a pivot table? Or Advanced filter?


    Regards, TMS

  6. #6
    Registered User
    Join Date
    11-27-2012
    Location
    Asheville, NC
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Over 200,000 lines and need a macro to calculate matching PO valuse

    I've attached a picture of the spreadsheet. Best I could do.

    My sum if statement =IF(SUMIF(H:H,H2,K:K)=0,"remove","keep") Once they were labeled I was going to delete the rows that said remove. If even tried limiting the rows by changing the H:H to H2:H206000, and the same in column K. That didn't return the correct results at all.
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Over 200,000 lines and need a macro to calculate matching PO valuse

    This is an Excel forum, so it would be helpfull is you post your Excel file, without confidentional information.

    Obviously, not the full 200,000 lines
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  8. #8
    Registered User
    Join Date
    11-27-2012
    Location
    Asheville, NC
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Over 200,000 lines and need a macro to calculate matching PO valuse

    Actually it was column J:J. Anyway... the reference number is the PO number. There are several hundred different PO numbers down the column. I need to total all of the same PO numbers with their corresponding dollar amounts in column J.

    Thanks again

  9. #9
    Registered User
    Join Date
    11-27-2012
    Location
    Asheville, NC
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Over 200,000 lines and need a macro to calculate matching PO valuse

    Maybe this will be more helpful. see attached
    Attached Files Attached Files

  10. #10
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Over 200,000 lines and need a macro to calculate matching PO valuse

    If you can upload a small sample with ALL HEADERS and some data maybe 4 to 5 ref numbers with 1 or 2 of them needing deletedd I cancode you up something pretty quick.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  11. #11
    Registered User
    Join Date
    11-27-2012
    Location
    Asheville, NC
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Over 200,000 lines and need a macro to calculate matching PO valuse

    okay, just a second

  12. #12
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Over 200,000 lines and need a macro to calculate matching PO valuse

    It can be done with pivot table.

    see the attached file.
    Attached Files Attached Files

  13. #13
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Over 200,000 lines and need a macro to calculate matching PO valuse

    So do you want 1 line per Reference Number? Do you want all the Columns In the output?

  14. #14
    Registered User
    Join Date
    11-27-2012
    Location
    Asheville, NC
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Over 200,000 lines and need a macro to calculate matching PO valuse

    Sorry, took me a few minutes. Had to manipulate the data just to get you a general idea of what needs to match. They won't total to zero but they will sum to a number.

    Thanks
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    11-27-2012
    Location
    Asheville, NC
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Over 200,000 lines and need a macro to calculate matching PO valuse

    One line per reference number, with the total. All of the columns are not necessary. Just the Reference, Text, dollar amount, voucher and date are helpful to me.

    Thanks so much

  16. #16
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,651

    Re: Over 200,000 lines and need a macro to calculate matching PO valuse

    One option:

    use Dynamic Named Ranges

    Amount =Sheet1!$J$2:INDEX(Sheet1!$J:$J,COUNTA(Sheet1!$J:$J))
    Reference_Number =Sheet1!$H$2:INDEX(Sheet1!$H:$H,COUNTA(Sheet1!$H:$H))
    Formula: =IF(SUMIF(Reference_Number,H2,Amount)=0,"Remove","Keep")

    Second, better option, use a Pivot Table. See example.

    Regards, TMS
    Last edited by TMS; 11-27-2012 at 06:51 PM. Reason: Edit dynamic range and sample workbook

  17. #17
    Registered User
    Join Date
    11-27-2012
    Location
    Asheville, NC
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Over 200,000 lines and need a macro to calculate matching PO valuse

    thanks! Hadn't thought about the ranges!

  18. #18
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,651

    Re: Over 200,000 lines and need a macro to calculate matching PO valuse

    You're welcome.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  19. #19
    Registered User
    Join Date
    11-27-2012
    Location
    Asheville, NC
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Over 200,000 lines and need a macro to calculate matching PO valuse

    Mike, leaving work now, but will check back tomorrow. No pressure. I appreciate anything.

    thanks

  20. #20
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Over 200,000 lines and need a macro to calculate matching PO valuse

    Here's what I got before you replied back. test on a copy of your workbook. Be sure the sheet1 has the data and you have a 2nd sheet named sheet2. Output will goto sheet2. Let me know how it does for you.

    Please Login or Register  to view this content.
    And this one list just the 4 columns

    Please Login or Register  to view this content.
    Last edited by mike7952; 11-27-2012 at 07:30 PM.

  21. #21
    Registered User
    Join Date
    11-27-2012
    Location
    Asheville, NC
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Over 200,000 lines and need a macro to calculate matching PO valuse

    Mike,

    Thank you SOOOO much. Both worked perfectly. I will use the second one you set up for me. Four columns of data popped up on the second tab just as I wanted them. I'm not savy enough to do this. I REALLY appreciate your help!

    THANKS AGAIN,

    Karen

  22. #22
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Over 200,000 lines and need a macro to calculate matching PO valuse

    And my solution in #12.

+ 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