+ Reply to Thread
Results 1 to 8 of 8

Subtraction

  1. #1
    Registered User
    Join Date
    11-05-2007
    Posts
    8

    Question Subtraction

    I have a very complex spreadsheet and I've encountered a problem I can't find a solution to..

    Here is a snippet with my problem:

    Please Login or Register  to view this content.
    Excel has to check if cell A3 has a number in it, if true, then A20-A3
    If A3 is blank, then check cell A2. If it has a number, then A20-A2
    If A2 is blank, then A20-A1 (because A1 will always have a number)

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Need help with Subtract formula

    Assuming they are truly blank

    A21: =A20-LOOKUP(9.99999999999999E+307,A1:A3)

    Or alternatively if as implied in your sample A1:A3 are listed in Ascending order (ie A2 always > A1 if populated and so on)

    A21: =A20-MAX(A1:A3)

  3. #3
    Registered User
    Join Date
    11-05-2007
    Posts
    8

    Re: Need help with Subtract formula

    Thanks for the help, but this didn't work in my spreadsheet.
    It says there's an error in formula and highlights this part: 9.99999999999999E

    I did make a mistake in my sample though, when labeling the headings..
    My spreadsheet is horizontal, so it's A1, B1, C1, G1, H1, but I did modify the formula you gave to go horizontal.

    And I actually simplified the sample, but in reality I have other columns in between the columns where actual data is.. maybe I should just give you the whole section of the spreadsheet.

    Please Login or Register  to view this content.
    Here is what I need to do: (O8+P8+R8+S8)-L8(if it's populated), if not check J8, if empty then subtract number in H8.

    H8 will always have a number in it, but formula should only subtract one number.
    columns I8, K8, M8 and N8 are just percentages and text info, they are not used by formula.

    Thanks again.

    Quote Originally Posted by DonkeyOte View Post
    Assuming they are truly blank

    A21: =A20-LOOKUP(9.99999999999999E+307,A1:A3)

    Or alternatively if as implied in your sample A1:A3 are listed in Ascending order (ie A2 always > A1 if populated and so on)

    A21: =A20-MAX(A1:A3)

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Need help with Subtract formula

    You don't specify your geo location in your profile - I suspect however your based in Central / Eastern Europe and as such the delimiter in your locale is ; rather than , as per my example (UK).
    (this is why it's a good reason to specify where on the planet you reside - there are differences in syntax)

    Anyway... based on your last post and again assuming H,J,L are always in ascending order (ie J >= H and L >= J when populated) then:

    =SUM(O8:S8)-MAX(H8,J8,L8)

    If that's not always the case probably just easiest (given only 3 cells) to revert to an embedded IF

    =SUM(O8:S8)-IF(SUM(L8);L8;IF(SUM(J8);J8;SUM(H8)))

  5. #5
    Registered User
    Join Date
    11-05-2007
    Posts
    8

    Re: Need help with Subtract formula

    Thanks again.

    H,J,L are not always in ascending order, so I need to use the 2nd formula.. but I have tried it and I always get a 0 result. Any ideas?

    By the way, I'm located in Russia but my laptop is from US and Excel is US-based... I use a semicolon as a delimiter.

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Need help with Subtract formula

    Sounds like the numbers are in fact stored as text.

    SUM will not explicitly coerce -- eg

    A1 holds "0" as text and B1 "10"

    SUM(A1:B1) -> 0

    whereas

    A1+B1 returns 10

    the latter is explicitly coercing the text values to numbers via addition.

    Why use SUM ?

    Well I used SUM on the off chance the cells contained values that could not be coerced without error eg

    A1: "Apple"
    B1: 10

    =SUM(A1:B1) --> 10

    whereas

    =A1+B1 -> #VALUE! as "Apple" can not be coerced to Number

    Better to enter numbers as numbers.

    If you can, post a sample.

    Regards delimiter - this is based on the client locale
    (ie as determined by the Regional Settings [Control Panel]).

  7. #7
    Registered User
    Join Date
    11-05-2007
    Posts
    8

    Re: Need help with Subtract formula

    I got it to work, had to fix one thing in the formula...

    =SUM(O8:S8)-IF(SUM(L8);L8;IF(SUM(J8);J8;SUM(H8)))

    =SUM(O8:R8)

    because formula itself is in cell S8

    Works great, thanks for your help!

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Need help with Subtract formula

    because formula itself is in cell S8
    Sorry, my bad, I should read more carefully!
    (though you didn't mention a circular reference warning...)

+ 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