Excel formula to check if previous column has N/A - excel

I am after a function that checks if 8 consecutive values are all greater than the average of the data (C29) and then return the last cell in the array of 8 if this is true. I have a working formula, which is
=IF(D38>$C$29,NA(),(IF(D38>$C$29,NA(),(IF(D39>$C$29,NA(),(IF(D40>$C$29,NA(),(IF(D41>$C$29,NA(),(IF(D42>$C$29,NA(),(IF(D43>$C$29,NA(),(IF(D44>$C$29,NA(),(IF(D45>$C$29,NA(),(IF(D46>$C$29,NA(),D46)))))))))))))))))))
However now I would like to add another test to this: if the corresponding cell in the column before it (I46) contains N/A, then I would like it to return the value of the formula above. But, if I46 contains a value, then I would like this cell to return N/A. I am struggling to wrap my head around how I can put this in, and whether to put it at the start or the end of the nested IF.
Many thanks for any help!

Use the following template:
=IF(ISNA(I46),formula that you already have,NA())
Which would be:
=IF(ISNA(I46),IF(D38>$C$29,NA(),(IF(D38>$C$29,NA(),(IF(D39>$C$29,NA(),(IF(D40>$C$29,NA(),(IF(D41>$C$29,NA(),(IF(D42>$C$29,NA(),(IF(D43>$C$29,NA(),(IF(D44>$C$29,NA(),(IF(D45>$C$29,NA(),(IF(D46>$C$29,NA(),D46))))))))))))))))))),NA())
I haven't tested this, but am taking at face value your statement that the formula you have now does what you want.

Related

Use a combined formula to return the value of a cell

I am trying to obtain the value of a cell that is in a different sheet, from a formula that returns the value of the row where it finds a match.
Basically, what I'm trying to imitate is:
=Sheet!Column Row
But as follows
=Sheet!Column Formula (Which returns the row that meets the conditions of the formula)
The problem is that I tried concatenating the name of the sheet, the column and the result of the formula (row), which works, since I get, for example:
=Risks!K3
But that's all, I get a kind of string and in reality I would need that result to also be calculated by excel and return, precisely, the value of cell K3.
Is there any way to solve it?
Use INDEX:
=INDEX(Risks!K:K,formulathatreturns3)

Excel formula unique list formula not working, if counta = 1

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.

Match to return all values instead of just first in a column

I am trying to find all the cells that have the value 21 in the column AGE. I currently have the following formula which works fine with returning just the first TRUE value:
=MATCH(21,AGE,0)
However, it does not continue through the whole column to return the rest of the results. Any help will be extremely appreciated.
Use AGGREGATE like this:
=IFERROR(INDEX(A:A,AGGREGATE(15,6,ROW($B$2:$B$7)/($B$2:$B$7=21),ROW(1:1))),"")
as it is dragged/copied down it will get the next in the line, until it finds no more, then it will fill the cell with "".

Sum all value of row when find a specific word in a column

I want to sum all values of one row (there are a lot of column) if there is a specific value in the first column.
Below follow the problem:
Link with the image
I want to find API Rheology and then find Cond. Time, with verified this two conditions, sum all values of the row.
    
You need to check the value of the first column with an "IF" function, and then if it's true, use "SUM" to find the total.
For example, if your first column is in a1, and your data goes from a1 to z1, than your formula should look like this:
=IF(A1="[check value]",SUM(A1:Z1),"")
Where you replace [check value] with what value you are looking for and "" with what you want to display if the value is not there. Putting "" will leave the cell blank.
If you want to be more specific and check if the first column contains a value, then you need to use:
=IF(ISNUMBER(SEARCH("[check value]",A1)),SUM(A1:Z1),"")
With the same arguments as before.
If you want to find multiple values than you need to use the AND function, so your function becomes:
=IF(AND(ISNUMBER(SEARCH("[check value]",A1)),ISNUMBER(SEARCH("[check value 2]",A1))),SUM(A1:Z1),"")
This will check if cell A1 contains both strings. If you want to check two different cells, then just replace the second A1 with whatever other cell you want.
If you want to find the string within a column of cells, replace the "A1"s with the list of cells you are looking for the string in. e.g. A1:Z1
The reason this works is because SEARCH returns a number based on where the [check value] is found within cell A1, or an error if the string doesn't appear. ISNUMBER returns TRUE if SEARCH return a number, not an error. Finally, IF checks if ISNUMBER is true or false, and returns the sum of your numbers if true and a blank space if not.
Hope this helped.
The sample data image seemed incomplete so I added a few things.
    
The formula in AE65 is,
  
This formula looks down column A for the name of the test (e.g. API Rheology in AC65) then locates the next occurrence of the reported result section (e.g. Cond Time (min) from AD65). Having located that row, it sums columns C:Z.

Excel formula to return a value from a range where conditional statements are true

I've searched for an answer for this for awhile now but haven't had any luck. It's a bit difficult to put into words, so please let me know if anything's unclear.
What I want is a way to perform conditional statements on two columns. When both conditions are true, I want to return the value from a third column that is in the same row as where these conditions were met. So if the conditions are true in D5 and C5, I want to return the value from Q5 into the cell with the formula. The conditional statements are easy enough but I haven't figured out the last step yet.
If I use the following formula, I get 1 in the cell with the formula, which is right.
=IF(AND('Stata Output'!D2:D6='Backcheck schedule and results'!C2, 'Stata Output'!C2:C6=1),1,0)
However, replacing 1 in the formula with the range of cells that I want to pull the value from gives me a zero every time, which I know is wrong. For this latter formula I'm using:
=IF(AND('Stata Output'!D2:D6='Backcheck schedule and results'!C2, 'Stata Output'!C2:C6=1),'Stata Output'!Q2:Q5,0)
Any ideas on where I'm messing up?
Thanks!
Give this a shot - I'm sure there is a simpler way but it seems to get the job done (make sure to enter as an array formula with Control+Shift+Enter):
=INDEX('Stata Output'!$D$2:$Q$6,MATCH(1,(--('Stata Output'!$C$2:$C$6=1)*--('Stata Output'!$D$2:$D$6="Backcheck schedule and results")),0),14)
What this does is take your entire table as the range (first argument to INDEX, then uses MATCH to find the row where both of your conditions are met (in this case, column C must be 1 and the corresponding value in column D must be Backcheck schedule and results). You then search the resulting array for 1 (which indicates the match) and return column 14 (which represents column Q in our table). You can continue to add filters inside the MATCH() function as needed.
Note that this will match only the first 'hit'.
Looks like AND isn't working correctly in array formulas, so I would use this:
=IF(('Stata Output'!D2:D6='Backcheck schedule and results'!C2)*('Stata Output'!C2:C6=1)=1,'Stata Output'!Q2:Q5,0)
This will give you a new results column, that will be filled from the Q2:Q6 column for every matching row.
To use it, you should select all of the results column, input the formula and then use CTRL+SHIFT+ENTER.
Just make sure to use use ranges of the same size.
Try the following formula:
=LOOKUP(2,1/('Stata Output'!D2:D6='Backcheck schedule and results'!C2)/('Stata Output'!C2:C6=1),'Stata Output'!Q2:Q5)
If there is more than one row where both conditions are satisfied, this formula will return the col Q value from the last of those.

Resources