SOLVED

EXCEL IF FUNCTION

%3CLINGO-SUB%20id%3D%22lingo-sub-2479920%22%20slang%3D%22en-US%22%3EEXCEL%20IF%20FUNCTION%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2479920%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3ESo%2C%20for%20example%2C%20%3DIF((H2%3D%22%22)*(J2%3D%22%22)%2C%22%22%2CIF(H2%26gt%3BJ2%2C%22overload%22%2C%22apples%22))%3C%2FP%3E%3CP%3Ethis%20basically%20says%20if%20H2%20or%20J2%20are%20empty%20then%20return%20an%20empty%20string%20but%20if%20H2%20is%20greater%20than%20J2%20then%20return%20%22overload%22%20otherwise%20%22apples%22.%20Fine%20-%20ok.%26nbsp%3B%3C%2FP%3E%3CP%3ENow%2C%20if%20the%20values%20%22overload%22%20and%20%22apples%22%20are%20unknown%20when%20I%20write%20this%20code%20how%20do%20I%20get%20the%20output%20to%20give%20me%20%22whatever%20the%20value%20of%20this%20string%20is%22%3F%26nbsp%3B%20Thanks%20for%20any%20help.%20Dennis%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2479920%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2480055%22%20slang%3D%22en-US%22%3ERe%3A%20EXCEL%20IF%20FUNCTION%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2480055%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F995268%22%20target%3D%22_blank%22%3E%40DennisMetro%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EEnter%20the%20values%20you%20want%20to%20return%20in%20cells%2C%20e.g%20in%20Y1%20and%20Z1.%20You%20can%20then%20use%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3DIF(H2%26amp%3BJ2%3D%22%22%2C%22%22%2CIF(H2%26gt%3BJ2%2C%24Y%241%2C%24Z%241))%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2480085%22%20slang%3D%22en-US%22%3ERe%3A%20EXCEL%20IF%20FUNCTION%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2480085%22%20slang%3D%22en-US%22%3EHi%20Hans%2C%20Thanks.%20The%20problem%20is%20I%20don't%20know%20the%20values%20of%20Y1%20and%20Z1.%20There%20is%20a%20range%20of%20possible%20values.%20When%20I%20know%20the%20values%20for%20Y1%20and%20Z1%20I%20could%20just%20put%20them%20directly%20into%20the%20%22______%22%20part%20of%20the%20code.%20Hence%20my%20%22whatever%20the%20value%20of%20this%20string%20is%22.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2480089%22%20slang%3D%22en-US%22%3ERe%3A%20EXCEL%20IF%20FUNCTION%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2480089%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F995268%22%20target%3D%22_blank%22%3E%40DennisMetro%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20don%3Bt%20understand.%20What%20do%20you%20mean%20by%20%22whatever%20the%20value%20of%20this%20string%20is%22%3F%20What%20is%20%22this%20string%22%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

Hi,

So, for example, =IF((H2="")*(J2=""),"",IF(H2>J2,"overload","apples"))

this basically says if H2 or J2 are empty then return an empty string but if H2 is greater than J2 then return "overload" otherwise "apples". Fine - ok. 

Now, if the values "overload" and "apples" are unknown when I write this code how do I get the output to give me "whatever the value of this string is"?  Thanks for any help. Dennis

7 Replies
best response confirmed by DennisMetro (Contributor)
Solution

@DennisMetro 

Enter the values you want to return in cells, e.g in Y1 and Z1. You can then use

 

=IF(H2&J2="","",IF(H2>J2,$Y$1,$Z$1))

Hi Hans, Thanks. The problem is I don't know the values of Y1 and Z1. There is a range of possible values. When I know the values for Y1 and Z1 I could just put them directly into the "______" part of the code. Hence my "whatever the value of this string is".

@DennisMetro 

I don;t understand. What do you mean by "whatever the value of this string is"? What is "this string"?

Sorry! I've just now realized that your original solution works! My apologies. One question, if I may. As an old school type merchant - is there a good reference book for this sort of guidance? Years ago I liked to sit at the computer but look up stuff in a manual! I know it's all online these days but sometimes I just get it faster when I'm reading it on paper rather than 2 tabs open! I think it has to do with my age. Thanks again for your help.

@DennisMetro 

See for example Excel 2019 Bible 

Thank you very much.
Excel IF function is used to evaluate one or more criteria to determine what value should be returned.
If the number entered into the first argument meets the criteria (first and second arguments) specified in the third, fourth, and fifth arguments of that function then it will return a "true" value, otherwise it will return "false". Here are some examples for you:
=IF(A2="", "N/A", A2+B3) -Returns a formula if item from cell A2 does not equal something else.= = =IF(RAND()>"0.05","No Conditional Result Found Yet","Conditional Statement") -This would look at how many times

For a comprehensive resource about excel IF statement you can read here in detail
https://www.exceltrick.com/formulas_macros/excel-if-statement/