+ Reply to Thread
Results 1 to 15 of 15

subtracting column with criteria from other columns

  1. #1
    Registered User
    Join Date
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    subtracting column with criteria from other columns

    Is there a way to subtract a column that equals criteria of another column?

    example:

    A B C
    1 0
    1 1
    1 2
    1 3
    1 4
    1 4
    2 5
    2 6
    3 6
    1 7
    1 8

    So What i'm asking is Say A is a catagory and B is Second column C is the total time in that catagory. I want, if the criteria in A is 1, then subtract the column of the highest point in that first section from the lowest point. Then display that in C to show me the total time it was in Catagory 1. Then just have it continue on. thanks.
    Last edited by TheGame0135; 07-08-2010 at 10:55 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: subtracting column with criteria from other columns

    Do you mean?

    =MAX(IF(A$1:A$10,A1,B$1:B$10))-MIN(IF(A$1:A$10,A1,B$1:B$10))

    Adjust ranges to suit (keep as defined ranges, not whole columns)

    Then Confirm with CTRL+SHIFT+ENTER and not just ENTER and copy down.
    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
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: subtracting column with criteria from other columns

    no, your answer just gave me zeros...
    what I'm asking for is this...if I took the same data my answers would be.
    A B C
    1 0
    1 1
    1 2
    1 3
    1 4
    1 4 4
    2 5
    2 6 1
    3 6 1
    1 7
    1 8 1

    because the first set of 1's is 4-0, the first set of two's is 6-5, the first set of 3 is 6-0 (which i wanted to be counted as 1), and the second set of 1's is counted as 8-7. does this make sense? I need a automated way of doing this because I will be counting through thousands of points. So it won't always have the same numbers or ranges.

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

    Re: subtracting column with criteria from other columns

    Make the numbers start in Row 2.. then in C2:

    Please Login or Register  to view this content.
    confirmed with CTRL+SHIFT+ENTER and copied down

    Note: For the single value of 3 in column A, I get 0 since both max and min are 6.... ???

  5. #5
    Registered User
    Join Date
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: subtracting column with criteria from other columns

    i've been trying your code, and i keep getting div/o errors...

  6. #6
    Registered User
    Join Date
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: subtracting column with criteria from other columns

    ooops i forgot to hit CRTL+SHIFT+ ENTER, it worked perfectly thank you so much! now i get to put it into Matlab, oh the thrill of that program, why can't eveyrthing work in excel lol!

  7. #7
    Registered User
    Join Date
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: subtracting column with criteria from other columns

    although this does work we still have that zero issue, is there a way I can put in there somewhere if=0 make the answer 1?

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

    Re: subtracting column with criteria from other columns

    Maybe:

    Please Login or Register  to view this content.
    CSE confirmed again

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

    Re: subtracting column with criteria from other columns

    As long as you don't expect negatives... then maybe:

    Please Login or Register  to view this content.
    CSE confirmed again

  10. #10
    Registered User
    Join Date
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: subtracting column with criteria from other columns

    there definitely won't be any negatives i'll try this

  11. #11
    Registered User
    Join Date
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: subtracting column with criteria from other columns

    post #9 didn't not work, i'm trying 8 now

  12. #12
    Registered User
    Join Date
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: subtracting column with criteria from other columns

    post 8 worked beautifully thank you so much!

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

    Re: subtracting column with criteria from other columns

    Not even sure there is a difference... I was just trying to edit my quote to let you know about the negatives... I didn't change the formula (I don't think).. oh well, in the end we got you there

    Please mark thread as Solved.

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

    Re: subtracting column with criteria from other columns

    From PM:

    Quote Originally Posted by TheGame0135
    is there a way to do something similar to what you did, but instead of subtracting take the average?
    Try:

    Please Login or Register  to view this content.
    confirmed with CSE

  15. #15
    Registered User
    Join Date
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: subtracting column with criteria from other columns

    quite remarkable, thank you so much.

+ 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