Adding Positve and Negative Numbers
MZ Tools makes life easier for the Excel VBA coder
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 7 of 7

Thread: Adding Positve and Negative Numbers

  1. #1
    New Member
    Join Date
    Apr 2002
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    Hi

    I would appreciate it if anyone could advise on how I could add a column of positve and negative numbers, so that the end result is the value of the total of the absolute number?

    -55
    85
    -52
    =192

    Thanks

  2. #2
    Board Regular eliW's Avatar
    Join Date
    Mar 2002
    Posts
    1,919
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hunter,
    Just enter:
    =SUM(ABS(A1:A3))
    Array enter by pressing ctrl+shift+enter
    Eli



  3. #3
    New Member
    Join Date
    Apr 2002
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi Eli

    Thank you so much for your wonderful help. It works.

  4. #4
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Denver, CO
    Posts
    1,743
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    A non-array solution would be
    =SUMIF(A1:A3,">0")-SUMIF(A1:A3,"<0")

    I would suggest going with eliW's answer as long you don't notice any performance issues (ie your have to use the formula many, many times)

  5. #5
    New Member
    Join Date
    Apr 2002
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi IML

    Thanks for your advice too. Your method works too and I would adopt your approach, as I do have some performance issues. I need to apply this formula across 10 columns actually.

    Best regards
    Hunter

    [ This Message was edited by: Hunter on 2002-04-19 06:19 ]

  6. #6

    Join Date
    Mar 2002
    Posts
    12
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Or :-

    =SUM(A1:A3)-SUMIF(A1:A3,"<0")*2

  7. #7
    New Member
    Join Date
    Apr 2002
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Hi Adcb

    Thanks a lot.

    Regards
    Hunter

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com