Consulting

Results 1 to 7 of 7

Thread: Solved: If statement

  1. #1
    VBAX Mentor Hoopsah's Avatar
    Joined
    Nov 2007
    Posts
    303
    Location

    Solved: If statement

    Hi,

    I have attached a copy of the spreadsheet I am trying to work out a calculation on.

    I want to calculate the band width of a pipe given certain criteria.

    =IF($C$20<C37,C37-$C$20,0)

    Works and gives me the correct result, however, want I want to incorporate is a further condition, so that the fomulas will say:

    If C20 < C37, then, C37 - C20, but, If C20 is less than C37 then no other calculations are necessary as it will always be smaller than the other options.

    So, if the calculation gives a result then no other calculations are required and should state zero.

    Hope this makes sense, any help appreciated,

    Cheers

    Hoopsah
    Attached Files Attached Files
    I am playing all the right notes, but not necessarily in the right order.
    Eric Morecambe

  2. #2
    VBAX Mentor Hoopsah's Avatar
    Joined
    Nov 2007
    Posts
    303
    Location
    Quick amendment to above,

    I think all I want is:

    If C20 < C39 then C39 - C20 else 0

    To also incorporate If D37 > 0 then 0 else D20 < C39 then D39 -C20 else 0

    If in the cells with the formula a positive result has been gained, it will be greater than zero so all the other cells can state zero, or else they do the calculation.......


    Hope this makes a bit more sense
    I am playing all the right notes, but not necessarily in the right order.
    Eric Morecambe

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    How about

    =IF(AND(COUNTIF($D$27:$D27,">0")=0,$C$20<$C37),$C37-$C$20,0)
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    VBAX Mentor Hoopsah's Avatar
    Joined
    Nov 2007
    Posts
    303
    Location
    Thanks Bob,

    It still completes the calculation even though it has found a result in the line above, I have tried:

    =IF(D36>0,0,IF($C$20<C37,C37-$C$20,0))

    Which does work, but not to sure how strong it is.
    I am playing all the right notes, but not necessarily in the right order.
    Eric Morecambe

  5. #5
    VBAX Mentor Hoopsah's Avatar
    Joined
    Nov 2007
    Posts
    303
    Location
    Nope,

    Mine only works for the line above, so every other line is correct.

    0
    250
    0
    1250
    0
    2250


    ???
    I am playing all the right notes, but not necessarily in the right order.
    Eric Morecambe

  6. #6
    VBAX Mentor Hoopsah's Avatar
    Joined
    Nov 2007
    Posts
    303
    Location
    Sorry Bob,

    I was to busy looking at mine and not updating your code to incorporate the correct cells.

    Mines works as long as you are only checking 2 lines,

    Yours, after a bit of inspection, works perfectly.

    Sorry for not getting it straight away, it works better and is more robust than mine,

    Thanks for your help Bob

    Gerry
    I am playing all the right notes, but not necessarily in the right order.
    Eric Morecambe

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    It worked here Gerry
    Attached Files Attached Files
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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