Excel Multiple If Statements showing False - excel

I have this IF statement:
=IF(AG3<=7,"1",IF(15<=AG3<=21,"2",IF(22<=AG3<=28,"3",IF(29<=AG3<=35,"4",IF(36<=AG3<=42,"5",IF(43<=AG3<=49,"6",IF(50<=AG3<=56,"7")))))))
but either it gives me a 1 or "FALSE"
All the values are within the ranges and should be showing various numbers

Excel does not use 50<=AG3<=56. The way Excel will read this is it will resolve AG3<=56 which will resolve to TRUE or FALSE which have the values of 1 and 0 respectively. And since 50 is greater than both those it will always return FALSE and since you did not specify a final false argument Excel returns FALSE
It needs to be AND(50<=AG3, AG3<=56)
Also "1" returns a number as text and not a true number, remove the quotes.
So:
=IF(AG3<=7,1,IF(AND(15<=AG3,AG3<=21),2,IF(AND(22<=AG3,AG3<=28),3,IF(AND(29<=AG3,AG3<=35),4,IF(AND(36<=AG3,AG3<=42),5,IF(AND(43<=AG3,AG3<=49),6,IF(AND(50<=AG3,AG3<=56),7,"Value not in specs")))))))
But based on your criteria you could use:
=IF(OR(AND(AG3>=8,AG3<=14),AG3>56),"Not to Spec",MATCH(AG3,{-1E+99,15,22,29,36,43,40}))

Don't use Nested IFs if you can avoid it. Instead, use a banded VLOOKUP: it's many times more efficient, and a heck of a lot simpler to troubleshoot. Something like the answer here:
Excel IF statement Not returning the appropriate Value
In your case, here's your lookup list:
Note that since you haven't specified what should happen between 8 and 14 or over 57 I have simply put =NA() in those bands.
And here's the result for a range of numbers:
...and here's the formula that was used in the second column of that second table (using table notation):
=VLOOKUP([#Value],Table3,2,TRUE)

Related

Excel french issue

I have Excel sheet with value and another column value that depend of theme
If value >48 the value will be 8 if <=40 value will be 0 if value inferior a 48 and supperieru a 40 value will be column -40 I tried this but didn't work
=SI(AH15>48,8,SI(ET(AH15>40,AH15<48,AH15-40))
Or english:
=IF(AH15>48,8,IF(AND(AH15>40,AH15<48,AH15-40))
You are throwing in an AND function to check multiple conditions in a wrong manner:
All these conditions ET(AH15>40,AH15<48,AH15-40) can never be true since the last parameter is a calculation. Either way, what you tried to do is maybe:
=SI(AH15<=40,0,SI(AH15>48,8,AH15-40))
Which translates to:
=IF(AH15<=40,0,IF(AH15>48,8,AH15-40))
Try this one:
=IF(AH15>48,8,IF(AND(AH15>40,AH15<=48),AH15-40,0))
Hope it helps

Excel Statement with 4 conditions and 4 answers

All of the methods that I've used have 2 answer values (True or False).
How can I get the following with a formula?
If A1=1 then it's 11, if A1=2 the answer is 22, if A1=3 then it's 33, if A1=4 it's 44.
If the value your are evaluating is in cell A1, then the nested function would be as follows:
IF(A1=1,11,IF(A1=2,22,IF(A1=3,33,IF(A1=4,44,""))))
I put the 2 double commas at the end so the formula returns a blank instead of false.
I don't know if that's what you are asking about, but you can make multiple (nested) IF statements in one. For example:
IF(1=2;TRUE;IF(2=2;TRUE;FALSE))
You just put another IF in the FALSE part of IF statement. If that's not it, can you give a piece of the statement you tried and precise more what do you want?
=IF(AND(INT(A1)=A1,A1<=4,A1>=1),A1*11,"")
Now the above works for the condition you placed in your example, however if one were to go by your title alone you have a couple of options you could go with.
You first Option would be nested IF statements. Like you said each IF function has TRUE or FALSE. The trick is to put another IF function in for the TRUE result and another in for the FALSE results
IF(CHECK1, IF(CHECK2, TRUE2, FALSE2),IF(CHECK3, TRUE3, FALSE3))
The above give 4 potential results based on only 3 checks. Another option would be to do a check and supply a value for a TRUE result and another IF for a false result. Keep repeating the process. Conversely you could go the same route flipping TRUE FALSE option. It might look something like this:
IF(CHECK1, TRUE1, IF(CHECK2, TRUE2, IF(CHECK3, TRUE3, FALSE3)))
FALSE3 would be the result of all previous checks failing.
So for your case, your nested IF could look like (assuming the only valid entries are 1, 2, 3 and 4):
IF(A1=1,11,IF(A1,2,22,IF(A1=3,33,44)))
OR
IF(ISODD(A1),IF(A1=1,11,33),IF(A1=2,22,44))
and there are other options to work through the logic. there are also other checks you could be doing and results being displayed if your entries in A1 were not limited to the integers 1,2,3 and 4.
Now because you example is using the sequential integers 1,2,3 and 4 you could also use the CHOOSE function. Alternatively if you can make your criteria evaluate to sequential integers stating at 1 the CHOOSE function would work as well. Supply choose with an integer as the first argument and it will return the corresponding argument in the list that follows
CHOOSE(ARGUMENT,RESULT1, RESULT2,...,RESULTn-1, RESULTn)
In your case it would look something like:
CHOOSE(A1,11,22,33,44)
If you can not get sequential numbers for whatever reason and the gap is numbers is small and you are in the low integer count, you could leave a gap in results by providing "", or 0). lets say you has 1,3 and 4 as potential arguments, then your choose might look like:
CHOOSE(A1,11,"",33,44)
=IF(A1<>"",INDEX({11;22;33;44},A1),"")
=IF(AND(ISNUMBER(A1),A1<=4),A1*11,"")

Excel return true if number is within range

My problem
I have a list of values (List 1) that have the following pattern...
1234-COD-125
I have another list (List 2), which follow the pattern...
12345(1234-COD-100 - 1234-COD-150)
I need to search List 2 and return True if the value in List 1 is within range. So for example..
List 1 Result List 2
1234-COD-125 TRUE 12345(1234-COD-100 - 1234-COD-150)
1234-COD-126 TRUE 12345(4567-BAH-100 - 4567-BAH-150)
1234-COD-155 FALSE
4567-BAH-125 TRUE
4567-BAH-126 TRUE
4567-BAH-155 FALSE
Background
The first part (1234-COD) is the vendor ID and code. The last part (125) is the order ID. Different vendors can have the same order ID, so my lookup needs to account for the vendor.
What I've done so far
I have written a series of formulas which extract parts of the string. For instance, for
12345(1234-COD-100 - 1234-COD-150)
I have extracted the following in individual cells
100
150
COD
1234-COD-100
1234-COD-150
I know I can create a series to manually populate each order ID within range, then perform a lookup but I have hundreds of values in List 2 so this isn't an option.
Another option is to take the value in List 2 (12345(1234-COD-100 - 1234-COD-150) and check if every number in the range 100-150 is found in List 1.
I would like to be able to use a formula (or even VBA) to achieve this, but haven't been able to get any further. Any help would be greatly appreciated!
Parsing text is always problematic. The following will return what you want:
=SUMPRODUCT((A2>=TRIM(LEFT(MID($C$2:$C$3,FIND("(",$C$2:$C$3)+1,LEN($C$2:$C$3)),FIND(" - ",MID($C$2:$C$3,FIND("(",$C$2:$C$3)+1,LEN($C$2:$C$3)))-1)))*(A2<=SUBSTITUTE(TRIM(MID($C$2:$C$3,FIND(" - ",$C$2:$C$3)+3,LEN($C$2:$C$3))),")","")))>0
But it depends exclusively on the pattern you are showing. Specifically that the range is always in () and the two ranges are separated by -

combining IF and AND statement not working in excel

I am trying to calculate the percentage, here the rules are as follows:
01. Employees working in IT department for more than 10 years will get 7% and rest of the IT guys will get 6.5%
02. And for rest of the departments, we have different percentages
Here H column represents various departments and F is working experience and in column I we're getting the main value from which we have to calculate the percentages.
Here's what I tried
=IF(AND(H5="IT",F5<10),I5*6.5%,I5*7%,IF(H5="PRODUCTION",I5*9%,IF(H5="MARKETING",I5*6%,IF(H5="LAW",I5*6%,IF(H5="HR",I5*9.36%)))))
This is showing You've entered too many arguments
Your first If statement, really had one too many argument.
=IF(AND(H5="IT",F5<10),I5*6.5%,IF(H5="PRODUCTION",I5*9%,IF(H5="MARKETING",I5*6%,IF(H5="LAW",I5*6%,IF(H5="HR",I5*9.36%,I5*7%)))))
Since each new if is nested as the FALSE eventuality. Look at the end for that 7%.
Edit:
My bad(reading your comment made me realize), there are two error in your formula.
One has been discussed, the second is how you nested those IT percentage.
=IF(AND(H5="IT",F5>=10),I5*7%,IF(AND(H5="IT",F5<10),I5*6.5%,IF(H5="PRODUCTION",I5*9%,IF(H5="MARKETING",I5*6%,IF(H5="LAW",I5*6%,IF(H5="HR",I5*9.36%,""))))))
In this version I added another IF statement. We could have avoided it by defining either one of the IT's rate as the ELSE result same as my initial answer. Now all predictable eventuality have their own TRUE match. An unexpected value will return an empty string. Maybe you want it to be 0 instead...
(1) IF(AND(...))= conditions
(2) I5 * 6.5% = value if true
(3) I5 * 7% = value if false
Therefore, you already indicate value if false and another if statement is not allowed. I would remove (3) and put it to the very end of your formula. As such, once none of the previous conditions are met, it will automatically take on the value of 7%.

Return a row number that matches multiple criteria in vbs excel

I need to be able to search my whole table for a row that matches multiple criteria. We use a program that outputs data in the form of a .csv file. It has rows that separate sets of data, each of these headers don't have any columns that are unique in of them self but if i searched the table for multiple values i should be able to pinpoint each header row. I know i can use Application.WorksheetFunction.Match to return a row on a single criteria but i need to search on two three or four criteria.
In pseudo-code it would be something like this:
Return row number were column A = bill & column B = Woods & column C = some other data
We need to work with arrays:
There are 2 kinds of arrays:
numeric {1,0,1,1,1,0,0,1}
boolean {TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE}
to convert between them we can use:
MATCH function
MATCH(1,{1,0,1,1,1,0,0,1},0) -> will result {TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE}
simple multiplication
{TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE}*{TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE} -> will result {1,0,1,1,1,0,0,1}
you can can check an array in the match function, entering it like in the picture below, be warned that MATCH function WILL TREAT AN ARRAY AS AN "OR" FUNCTION (one match will result in true
ie:
MATCH(1,{1,0,1,1,1,0,0,1},0)=TRUE
, YOU MUST CTR+SHIFT+ENTER !!! FOR IT TO GIVE AN ARRAY BACK!!!
in the example below i show that i want to sum the hours of all the employees except the admin per case
we have 2 options, the long simple way, the complicated fast way:
long simple way
D2=SUMPRODUCT(C2:C9,(A2=A2:A9)*("admin"<>B2:B9)) <<- SUMPRODUCT makes a multiplication
basically A1={2,3,11,3,2,4,5,6}*{0,1,1,0,0,0,0,0} (IT MUST BE A NUMERIC ARRAY TO THE RIGHT IN SUMPRODUCT!!!)
ie: A1=2*0+3*1+11*1+3*0+2*0+4*0+5*0+6*0
this causes a problem because if you drag the cell to autocomplete the rest of the cells, it will edit the lower and higher values of
ie: D9=SUMPRODUCT(C9:C16,(A9=A9:A16)*("admin"<>B9:B16)), which is out of bounds
same as the above if you have a table and want to view the results in a diferent order
the fast complicated way
D3=SUMPRODUCT(INDIRECT("c2:c9"),(A3=INDIRECT("a2:a9"))*("admin"<>INDIRECT("b2:b9")))
it's the same, except that INDIRECT was used on the cells that we want not be modified when autocompleting or table reorderings
be warned that INDIRECT sometimes give VOLATILE ERROR,i recommend not using it on a single cell or using it only once in an array
f* c* i cant post pictures :(
table is:
case emplyee hours totalHoursPerCaseWithoutAdmin
1 admin 2 14
1 him 3 14
1 her 11 14
2 him 3 5
2 her 2 5
3 you 4 10
3 admin 5 10
3 her 6 10
and for the functions to check the arrays, open the insert function button (it looks like and fx) then doubleclick MATCH and then if you enter inside the Lookup_array a value like
A2=A2:A9 for our example it will give {TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE} that is because only the first 3 lines are from case=1
Something like this?
Assuming that you data in in A1:C20
I am looking for "Bill" in A, "Woods" in B and "some other data" in C
Change as applicable
=IF(INDEX(A1:A20,MATCH("Bill",A1:A20,0),1)="Bill",IF(INDEX(B1:B20,MATCH("Woods",B1:B20,0),1)="Woods",IF(INDEX(C1:C20,MATCH("some other data",C1:C20,0),1)="some other data",MATCH("Bill",A1:A20,0),"Not Found")))
SNAPSHOT
I would use this array* formula (for three criteria):
=MATCH(1,((Range1=Criterion1)*(Range2=Criterion2)*(Range3=Criterion3)),0)
*commit with Ctrl+Shift+Enter

Resources