Consulting

Results 1 to 9 of 9

Thread: Solved: IF AND PROBLEM

  1. #1
    VBAX Mentor jammer6_9's Avatar
    Joined
    Apr 2007
    Location
    Saudi Arabia
    Posts
    318
    Location

    Solved: IF AND PROBLEM

    Hi all,

    Whats the problem of my formula? I have 9 logical conditions. The first 6 is okay but on the last 3 I am facing difficulties. Is there any limitation of using AND? Formula below is pointing on 2nd AND of the last 3 conditions...


    =IF(AND(B58="L",M58<=0.15%),1090,IF(AND(B58="L",M58<=0.20%),1045,IF(AND(B58 ="L",M58<=0.25%),1000,IF(AND(B58="M",M58<=0.15%),840,IF(AND(B58="M",M58<=0. 20%),795,IF(AND(B58="M",M58<=0.25%),750,IF(AND(B58="S",M58<=0.15%),500,IF(AND(B58="S",M58<=0.20%,545,IF(AND(B58="S",M58<=0.25%),500,"")))))))))
    T-ogether
    E-veryone
    A-chieves
    M-ore


    One who asks a question is a fool for five minutes; one who does not ask a question remains a fool forever.

  2. #2
    VBAX Mentor jammer6_9's Avatar
    Joined
    Apr 2007
    Location
    Saudi Arabia
    Posts
    318
    Location
    Remarks (EXCEL HELP)
    • Up to seven IF functions can be nested as value_if_true and value_if_false arguments to construct more elaborate tests.
    T-ogether
    E-veryone
    A-chieves
    M-ore


    One who asks a question is a fool for five minutes; one who does not ask a question remains a fool forever.

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Have a look at C Pearsons solution
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    VBAX Mentor jammer6_9's Avatar
    Joined
    Apr 2007
    Location
    Saudi Arabia
    Posts
    318
    Location
    Quote Originally Posted by mdmackillop
    Have a look at C Pearsons solution
    Create a name to represent a formula or a constant

    1. On the Insert menu, point to Name, and then click Define.
    2. In the Names in workbook box, enter the name for the formula.
    3. In the Refers to box, type = (equal sign), followed by the formula or the constant (constant: A value that is not calculated and, therefore, does not change. For example, the number 210, and the text "Quarterly Earnings" are constants. An expression, or a value resulting from an expression, is not a constant.) value.

    Exact Solution... Thanks!
    T-ogether
    E-veryone
    A-chieves
    M-ore


    One who asks a question is a fool for five minutes; one who does not ask a question remains a fool forever.

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    =IF(OR(M58>0.25%,SUM(--COUNTIF(B58,{"L","M","S"}))=0),"",
    N(SUM(COUNTIF(B58,{"L","M","S"})*{1000,750,500},LOOKUP(M58,{0,0.0015001,0.0 02001},{90,45,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

  6. #6
    VBAX Mentor jammer6_9's Avatar
    Joined
    Apr 2007
    Location
    Saudi Arabia
    Posts
    318
    Location
    Quote Originally Posted by xld
    =IF(OR(M58>0.25%,SUM(--COUNTIF(B58,{"L","M","S"}))=0),"",
    N(SUM(COUNTIF(B58,{"L","M","S"})*{1000,750,500},LOOKUP(M58,{0,0.0015001,0.0 02001},{90,45,0}))))
    You are a xld ... You simplify things... Formula is perfect and you just made me genius to my Boss
    T-ogether
    E-veryone
    A-chieves
    M-ore


    One who asks a question is a fool for five minutes; one who does not ask a question remains a fool forever.

  7. #7
    VBAX Mentor asingh's Avatar
    Joined
    Jul 2005
    Posts
    307
    Location
    Quote Originally Posted by xld
    =IF(OR(M58>0.25%,SUM(--COUNTIF(B58,{"L","M","S"}))=0),"",
    N(SUM(COUNTIF(B58,{"L","M","S"})*{1000,750,500},LOOKUP(M58,{0,0.0015001,0.0 02001},{90,45,0}))))
    Will COUNTIF(B58,{"L","M","S"}) work as a single formula on a given range..

    For exampe:COUNTIF(B5:B8,{"a","b","c"})

    and it returns me the count of existence of a,b,c in my range.

    I tried it..it gives a one each time..??

  8. #8
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    The COUNTIF will return an array, so you are just seeing the first item in the array. To count them all, you have to sum the array

    =SUM(COUNTIF(B5:B8,{"a","b","c"}))
    ____________________________________________
    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

  9. #9
    VBAX Mentor asingh's Avatar
    Joined
    Jul 2005
    Posts
    307
    Location
    Perfect..works..!

    Great -- thanks.

Posting Permissions

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