+ Reply to Thread
Results 1 to 10 of 10

Summing up opposite numbers in a column based on criteria....

  1. #1
    Registered User
    Join Date
    06-10-2009
    Location
    Austin, TX
    MS-Off Ver
    Professional Plus 2010
    Posts
    21

    Summing up opposite numbers in a column based on criteria....

    Imagine column A sorted by invoice numbers. Column B has payments applied but due to movement between unapplied cash, some numbers appear as negatives and positives for the same invoice number.

    I want to have a formula which says that for each invoice number, look in column b and eliminate opposite numbers and post only unique values. Keep in mind that there may be multiple lines with the same invoice number.

    For example, starting with line 5, for invoice 123, payments 400 and -400 in line 5 and 17 and payments 315 and -315 in lines 7 and 9 will zero out but any other unique payment will be picked up and displayed in column C. Lines 5 and/or 17 will be blank in column C.

    Can anybody help please!

    Thank you.
    Last edited by rshukla; 06-29-2009 at 01:17 AM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Summing up opposite numbers in a column based on criteria....

    See attached for a suggested solution:

    Formula in C2:

    Please Login or Register  to view this content.
    copied down...

    This formula counts the number of "opposites" to the invoice and amount on the line and also determines if there is an even number or odd number of absolute values of that entry up to that point... so that it will blank out the first positve and second negative or vice versa, but not the third (if there is no fourth).

    For example, there are 3 entries of invoice Invoice/Acct # 123 with amounts 400, -400 and 400... only the first 400 and the -400 will be blanked, the 3rd will remain.. (unless a 4th opposite comes up).
    Attached Files Attached Files
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    06-10-2009
    Location
    Austin, TX
    MS-Off Ver
    Professional Plus 2010
    Posts
    21

    Re: Summing up opposite numbers in a column based on criteria....

    NBVC,

    Thank you so much for your reply. That formula is very close to what I need. I have finally figured out how to attach excel files to the message. Please review the attached file. It is a sample of the actual data I am using. I have added a column where it shows the desired result of the formula. I hope it helps.

    Some observations about the data;

    - Invoice numbers (Col. A) are not scattered. They always appear together as if the data itself was sorted by Col. A.

    - There may be any number of combinations of those pesky positive and negative amounts. Example (in different rows): -400, -400, -400, 400, 400, 400, -300 OR -400, 400, 100, -400, -400, 400. You will see some stuff like this in the attached file.

    But thanks a lot for all your help already. I'd be a very happy camper if you could please fix this for me.

    Thanks!
    Attached Files Attached Files

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Summing up opposite numbers in a column based on criteria....

    Try:

    Please Login or Register  to view this content.
    in G2, copied down.

    Remember to adjust ranges to suit your actual data if larger/smaller...
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    06-10-2009
    Location
    Austin, TX
    MS-Off Ver
    Professional Plus 2010
    Posts
    21

    Re: Summing up opposite numbers in a column based on criteria....

    NBVC,

    Sorry for the delayed reply. Busy day. I am loving your formula. Later tonight I will try it on a 35,000 line file. I am not expecting any issues.

    Will update you tomorrow. Thank you very much! I am not bad at excel, but I couldn't have figured this one out to save my life. My boss is delighted!

    Thanks again!

  6. #6
    Registered User
    Join Date
    06-10-2009
    Location
    Austin, TX
    MS-Off Ver
    Professional Plus 2010
    Posts
    21

    Re: Summing up opposite numbers in a column based on criteria....

    NBVC,

    I have checked it on a huge file and compared the output with our Accounting system. It was a huge database and it took me a while.

    There is only one glitch left to fix in the formula. Please review the attached file (rows 189 to 196 & 199 to 204). The formula is giving a blank result for positive and negative amounts showing up in the following combination;

    IN-SJ3-108128184 - 1,590.00
    IN-SJ3-108128184 - 1,590.00
    IN-SJ3-108128184 - 1,590.00
    IN-SJ3-108128184 - (1,590.00)
    IN-SJ3-108128184 - (1,590.00)
    IN-SJ3-108128184 - (1,590.00)
    IN-SJ3-108128184 - (1,590.00)

    In other words, it is not picking up an amount if the positive and negative amounts are the same dollar amount and grouped together.

    Thank you.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    06-10-2009
    Location
    Austin, TX
    MS-Off Ver
    Professional Plus 2010
    Posts
    21

    Re: Summing up opposite numbers in a column based on criteria....

    Invoice no. IN-SJ3-108128184 mistakenly appears in two separate places in the file. I was trying to check a different combination of those positive and negative amounts. Please see attached file... I changed the last digit from 4 to 5.

    There's 3 test cases in the file to fix.

    I am wondering if the formula is designed to check only a certain number of rows for the amount to be picked up. If so, any way we can change that a higher number of rows? I am trying to understand the formula so just ignore this post if not applicable. If I can help in any way, please let me know.

    Thank you for all your help and I'm sorry this is taking so much work.
    Attached Files Attached Files
    Last edited by rshukla; 06-17-2009 at 01:01 PM. Reason: Correct attachment error.

  8. #8
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Summing up opposite numbers in a column based on criteria....

    See attached.

    I used some Named Ranges to determine the individual group of like invoice numbers.

    To create the Named Ranges...

    Go to G2 and then go to Insert|Name|Define

    Enter C_Start in Names in this workbook field and enter formula:

    Please Login or Register  to view this content.
    Then click Ok.

    Re-invoke Insert|Name|Define and enter C_End in Names in this workbook with formula:

    Please Login or Register  to view this content.
    Then Click Ok.

    In G2, Enter formula:

    Please Login or Register  to view this content.
    and copy down.

    Note: The named ranges are dynamic allowing you to add more accounts to the bottom with adjusting formulas.. you just need to copy formula in G down..

    Hope this does the trick.... it took a bit to think this one through.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    06-10-2009
    Location
    Austin, TX
    MS-Off Ver
    Professional Plus 2010
    Posts
    21

    Re: Summing up opposite numbers in a column based on criteria....

    Testing... testing...

    Everything is looking great so far! Variances are gone! Boss, this is magic...

    Testing...

  10. #10
    Registered User
    Join Date
    06-10-2009
    Location
    Austin, TX
    MS-Off Ver
    Professional Plus 2010
    Posts
    21

    Thumbs up Re: Summing up opposite numbers in a column based on criteria....

    NBVC,

    Your formula works wonderfully and I have had no variances in my data. You really did put in a lot of work in this problem and I am really thankful.

    - Rahul.

+ 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