I am not getting a positive when using the formula =IF(H3=OR(Sheet2!I:I),"PK","not PK")
Even when the value of H3 is in Column I on sheet 2. I only get "not PK"
Am I doing something wrong?
Try this formula instead.
=IF(COUNTIF(Sheet2!I:I,"="&H3)>0,"PK","NOT PK")
Basically it's counting how many times it finds a value equaling H3, and if that number is greater than 0, it reads "PK", otherwise "NOT PK".
Related
I want to count a range where one of my criterion is NOT less than or equal to a date in another cell. But blanks are okay, so I can't just say the criterion is greater than that date in the other cell. Meaning that I want to count the cells that are either blank or after the given date. I've tried the following criterion but get a parse error because of the last, bolded criterion:
=countifs(Sheet2!$B:$B,"Example",Sheet2!$E:$E,<>"<="&B2)
B2=3/31/2017
Sheet2!E:E are cells either with dates entered or left blank
Thanks for any help.
If I understand what you want, add the blanks to those that meet your criteria:
For example:
=COUNTBLANK(theRange)+COUNTIF(theRange,">"&A2)
where theRange refers to, for example B2:B10
one more for good measure:
=countif(Sheet2!$B:$B,"Example") - countifs(Sheet2!$B:$B,"Example",Sheet2!$E:$E,"<="&B2)
complementing #BigBen's response.
Try this:
=countifs(Sheet2!$B:$B,"Example",Sheet2!$E:$E,">="&B2)+countifs(Sheet2!$B:$B,"Example",Sheet2!$E:$E,"")
I want to count the cells that are either blank or after the given date
Try this:
=SUMPRODUCT(--($A$1:$A$16>E2)+--($A$1:$A$16=""))
This is how it works:
--($A$1:$A$16>E2 will return an array of 1 and 0, depending if cell value is *greater than value in E2. In this case we'll get {0;0;0;0;0;0;0;0;1;1;1;1;1;1;1;1}
--($A$1:$A$16="") will return an array of 1 and 0, depending if cell is blank or not. In this case we'll get {0;0;0;1;0;1;0;0;0;0;0;0;0;0;0;0}
+will sum up both arrays, so we get {0;0;0;1;0;1;0;0;1;1;1;1;1;1;1;1}
SUMPRODUCT will sum up that array into a single number, in this case, 10.
Other cases:
I have the following formula to make a unique list from column plant in table 15:
{=IFERROR(INDEX(Tabel15[Plant];MATCH(0;COUNTIF(Analyses!$Q$2:$Q2;Tabel15[Plant]);0));"")}
This formula is working, but when there is just 1 value in column plant the formula gives a value of 0. This is wrong because it should return the value.
Does anyone know how I can adapt this formula to make it work?
I wanted to change it to this:
{=IF(COUNTA(Tabel15[plant])>0;INDEX(Tabel15[Plant];MATCH(0;COUNTIF(Analyses!$Q$2:$Q2;Tabel15[Plant]);0));Kopie - datablad$G$2)}
But it doesn't work either.
Good mock example. Try and see if this works:
The formula counts the unique cells against another list. The unique list expects to take the first row, no matter what. It also expects you to have more than one value in your duplicate list. If it doesn't you can't compare since it expect duplicates and it throws an error, #N/A. This is mask as blank cell since it's wrapped in IFERROR:
"Unique formula" = IFERROR(INDEX(Tabel15[Plant],MATCH(0,COUNTIF($Q$1:Q2,Tabel15[Plant]), 0)),"")
To solve this we check how many values it exist in our duplicate list:
=IF(COUNTA(Tabel15[Plant])>1,... "Unique formula" ... ,Tabel15[Plant]) //***//
This will give us this result.
Then you probably don't want duplicates...
So we need to check if previous rows contain any of the values the formula would return.
The VLOOKUP formula do that for us, and as lookup value we use the formula above //***// and lookup range will be our current column: $Q$1:Q2. NOTICE this is a dynamic range so Q2 is relative reference (no $).
=IF(ISERROR(VLOOKUP(IF(COUNTA(Tabel15[Plant])>1,IFERROR(INDEX(Tabel15[Plant],MATCH(0,COUNTIF($Q$1:Q2,Tabel15[Plant]), 0)),""),Tabel15[Plant]),$Q$1:Q2,1,FALSE))
So the Final result we need to apply is this in Cell Q3:
=IF(ISERROR(VLOOKUP(IF(COUNTA(Tabel15[Plant])>1,IFERROR(INDEX(Tabel15[Plant],MATCH(0,COUNTIF(Analyses!$Q$1:Q2,Tabel15[Plant]), 0)),""),Tabel15[Plant]),Analyses!$Q$1:Q2,1,FALSE)),IF(COUNTA(Tabel15[Plant])>1,IFERROR(INDEX(Tabel15[Plant],MATCH(0,COUNTIF(Analyses!$Q$1:Q2,Tabel15[Plant]), 0)),""),Tabel15[Plant]),"")
The macro error can be ignored by:
If Not IsError(Sheets("Hulpblad").Range("B6").Value) Then
t = Sheets("Hulpblad").Range("B6").Value
'Code...
End If
there is no problem in your formula, it is just telling that there are blanks in the range, 0 means blank. the formula is treating the blank as a value and also considering it in the unique value calculations.
If you want to remove 0 you can just insert an if over your formula to remove it. like
=if(formula = 0, "", formula)
or in orignal form
=IF( (IFERROR(INDEX(Tabel15[Plant],MATCH(0,COUNTIF(Analyses!$Q$2:$Q2,Tabel15[Plant]),0)),""))=0,"",IFERROR(INDEX(Tabel15[Plant],MATCH(0,COUNTIF(Analyses!$Q$2:$Q2,Tabel15[Plant]),0)),""))
or go in the cell formatting and change the format to display 0 as a dash.
sometimes blank is also used as error checking, you can apply such formulae as well to check how many are blank, maybe that would someday be used to check any data entry problems.
In my excel file, I am trying to determine if a set of numbers is greater than the value of another cell.
I have written out an IF statement that only works sometimes depending on the range of the set of numbers. I have been able to replicate the problem but can't understand what is going wrong. I have included an example of my problem.
"B4" is equal to 2
"'Data Sheet'!A1:A10" is a set of 10 numbers from 1 to 10 inclusive.
My first statement (seen below) is working fine:
=IF(B4>'Data Sheet'!A1:A10,"Pass", "Fail")
which returns Fail, as expected.
However, when I change the statement to:
=IF(B4>'Data Sheet'!A6:A10,"Pass", "Fail")
It returns "#VALUE!".
Why does the range of values in the IF statement make a difference to whether it works or not?
Your formula is an array formula, and it is probably due to serendipity that your first formula is returning what you expect as an answer.
When you enter it into a cell as a non-array formula, which is what you are doing, it will return the value from the column A range that is in the same row as the formula.
Had you entered the first formula in Row 1, it would have returned "Pass" since it would be comparing B4 with A1.
If it is not in a row corresponding to a row in the range, it will return #VALUE.
If you confirm the formula as an array formula, by holding down ctrl + shift while hitting enter, then the formula will return an array of Pass;Fail depending on the relationship of B4 to each of the values in A1:A10. (or A6:A10). The visible value in a single cell will be the result of the first comparison.
So you will need to properly evaluate the array, in order to return whatever it is you want from the formula.
I'm not sure of exactly what you want.
If you want to determine if B4 is greater than any of the numbers in A1:A10, then try (entered normally):
If(B4 > MAX(A1:A10),"Pass","Fail")
If you want something else as a result, you will need to be more specific.
I'm getting the average % change among an array of cells (A1-D1). Cell A11 is =COUNT(1:1)-1 (to get the number of cells that actually contain anything). The formula I'm using to get the average is =SUMPRODUCT(OFFSET(B1,,,,A11)/OFFSET(A1,,,,A11))/A11-1,0) (someone on a different forum helped me out with that one). This works fine for the most part. The problem is that some of the cells--let's say A1 and B1--contain "0". This results in a "Divide by Zero" error. Is there a way to exclude any cell that contains zero from the calculation? Thanks!
Try using this formula to ignore the cells that would give a #DIV/0! error
=SUM(IFERROR(OFFSET(B1,,,,A11)/OFFSET(A1,,,,A11),0))/SUM(--ISNUMBER(OFFSET(B1,,,,A11)/OFFSET(A1,,,,A11)))
IFERROR in the numerator sets the result of any divisions by zero to zero.
ISNUMBER in denominator gives a TRUE for all divisions which are not divisions by zero, and this is converted to a '1' by the --.
The formula has to be entered as an array formula using CtrlShiftEnter
EDIT
=SUM(IFERROR(OFFSET(B1,,,,A11)/OFFSET(A1,,,,A11),0))/COUNTIF(OFFSET(A1,,,,A11),"<>0")
gives the same result and is shorter (note that if the last number i.e. D1 is zero, you don't get a #DIV/0! error).
Like the question, this assumes there are no empty cells between numbers - otherwise you couldn't use COUNT and OFFSET to get the range.
I have some data in excel and want to access certain rows with the offset function, however the function returns #VALUE! for my small dataset.
Using this, OFFSET(A2;0;0;COUNTA(A2:A99999);1) I get #VALUE!. When changing the formula to OFFSET(A2;0;0;100;1) I get a value.
Any suggestions, what I am doing wrong?
I appreciate your replies!
If =OFFSET(A2;0;0;COUNTA(A2:A99999);1) is your full formula you are getting a result with a hard-coded number due to Inferred Position (I hope that's the right term). This means that when you are referencing a range but are not processing the full range the operative cell is the one relative to the current position.
If you put =$A$2:$A$11 in D2 and fill down you will get processive results according to your row position that match column A. Keep filling down and you will get the #VALUE! error when you go past row 11.
This is why =OFFSET(A2; 0; 0; 100; 1) returns a zero and =OFFSET(A2; 0; 0; COUNTA(A2:A99999); 1) returns a #VALUE! error. The first formula is the same as saying =$A$2:$A$101 and it is returning zero because you put the formula in a cell that was above row 101 (referencing a blank cell in column A that returned a value of 0). The second (with the COUNTA function) is like saying =$A$2:$A$11 and you are putting it into a cell in row 13 (below row 11).
Addndum:
On a related note, these variations of the INDEX function and MATCH function are non-volatile and more functional than the OFFSET function while providing a cell range reference identical to what you were achieving with OFFSET and the COUNTA function.
'for text in a column
=$A$2:INDEX($A:$A, MATCH("zzz", $A:$A))
'for numbers in a column
=$A$2:INDEX($A:$A, MATCH(1e99, $A:$A))
'for unknown in a column
=$A$2:INDEX($A:$A, IFERROR(MATCH(1e99, $A:$A), MATCH("zzz", $A:$A)))
'for combined in a column
=$A$2:INDEX($A:$A, MAX(MATCH(1e99, $A:$A), MATCH("zzz", $A:$A)))
'I don't like COUNTA but it works as long as there are no blanks
=$A$2:INDEX($A:$A, COUNTA($A:$A))
There are many variations on this method. Perhaps you can use one of the above for your purposes.
OFFSET(A2;0;0;(range > 1);1) will return an array rather than the value of a single cell. This only makes sense if you put sum or some other aggregate function around it. (What are you trying to achieve with the formula?)
e.g.
=SUM(OFFSET(A2;0;0;COUNTA(A2:A99999);1))