Excel 2013: Using the Search()-function through a table column? - excel

I'm trying to search through a table column and use the Search()-function to find out if any of the words in the column appear in a given cell.
As you can see here, the formula returns FALSE, even though "Chicken" is in the list. If I move "Chicken" to the top in the column, it will return true. This leads me to believe that the formula only looks at the first item in the column.
Upon entering the formula, I used the CTRL+SHIFT+ENTER keys to make sure it's an array formula.
Does anyone know why it doesn't look through each of the rows in the column?
Edit: I guess the formula stops when it gets any value (even if that value is false)? Maybe there is a function for searching until true?

Try this non CSE formula:
=IF(SUMPRODUCT((ISNUMBER(SEARCH(Table1[Search words],A1)))*1)>0,TRUE,FALSE)
The reason is that without Sum() or Sumproduct, it is only returning the first iteration.

Related

How to see if multiple columns match different conditions and return text

I'd like to return a "u" if the cell to the left is in column I on my other tab AND if the cell underneath is in column F on the other tab. How would I go about this please?
So far I have in cell f7: =IFERROR(IF(VLOOKUP(F8,Table!I:I,1,0)<>"","u",0),"")
but I need to also look in Table!F:F to see if the date from the cell underneath is in it.
EXAMPLE
Here is my data in tab 1:
Here is what I'm looking to do in tab 2:
If I understand your question correctly this formula should provide what you are looking for.
=IFERROR(IF(AND(VLOOKUP(F8,Table!I:I,1,0)=F8,VLOOKUP(F9,Table!F:F,1,0)=F9),"u",0),"")
Using the AND() function requires both tests to be TRUE in order for the evaluations to be TRUE. An OR() allows both to be checked but returns TRUE if either is TRUE. So using the AND() checks both conditions and returns "u" in your IF statement only if both are TRUE.
I changed the logical criteria to equals just to be sure the values match.
Hi Becca,
It seems the part that I missed in the first attempt was the across. I think the vlookup is your easiest way to do this, but you may have to rearrange your columns. If you cut the column I:I on the table tab, and highlight column F:F right click and insert cut cells this will line the data up better for the vlookup. Now if you use the below formula you can compare across.
=IFERROR(IF(VLOOKUP(F8,Table!F:G,2,0)=F9,"u",0),"")
What this does is it finds the look up value and returns the value from the other column. Then it compares the returned value to the value in the cell underneath. If they match you get a "u" and if not, you get a "0". If the lookup is an error, you receive a blank.
Ok let's try this. A $ turns a relative reference into an absolute reference. The following looks up the name in column "A" and returns the date in column "B". It then compares that date to the value of row 10 of the current column. If it is drug across columns it will update to that column. If you wish to lock the column and unlock the row simply move the $ to before the "B" for the "B10" reference.
=IFERROR(IF(VLOOKUP($A2,Table!$A:$B,2,FALSE)=B$10,"U",0),"")
[![enter image description here][3]][3]
If you only care that the date is in the list below you could use an HLOOKUP.
=IFERROR(IF(VLOOKUP($A2,Table!$A:$B,2,FALSE)=HLOOKUP($B2,$10:$10,1,FALSE),"U",0),"")
Then you will have to use an index match however, this will not work on Excel 2019 or older. You will most likely need to use Excel 365. It will work best if you are always checking against the same reference (say B10), but you can drag it across.
=IFERROR(IF(INDEX(Table!$B:$B,MATCH($A2&B$10,Table!$A:$A&Table!$B:$B,0))=B$10,"u",0),"")

Extracting distinct values from a table in excel but a zero kept showing in between my results?

I'm trying to extract unique values from a list with empty cells in between in Excel. Currently, the formula I'm using is:
=IFERROR(INDEX('Raw List'!$D$5:$D$999,MATCH(0,COUNTIF($B$7:B7,'Raw List'!$D$5:$D$999),0)),"")
The 1st picture indicates the table (D5:D999) and the second picture is the target output. As you can see, the results is correct and it ignores duplicate values but then there's a "0" that keeps popping up and I'm not sure how to fix this.
Does anyone know what might cause this and how to fix the formula?
Thank you!
If you have Excel O365, with all the current functions, you can use the simpler formula:
=UNIQUE(FILTER(theRange,theRange<>""))
Note that you still have to filter out the blanks.
When the Countifs processes the range D5:D999 and gets as far as the first blank cell, it will return a count of zero, so you will get a match. Unfortunately, when Index refers to this blank cell it returns it as a zero, so that's where the zero comes from. You can fix it by checking that the current cell is non-blank as below. When the countifs runs out of non-blank non-duplicate cells, it will trigger the Iferror and return an empty string as expected.
=IFERROR(INDEX('Raw List'!$D$5:$D$999,MATCH(1,(COUNTIF($B$7:B7,'Raw List'!$D$5:$D$999)=0)*('Raw List'!$D$5:$D$999<>""),0)),"")

How to find the first value in a column larger than the previous value in the column

I'm looking for an excel formula to return the index of the first value in a large column such that ABS((COL)(ROW)-(COL)(ROW+2))< 0.1
Clearly, this is pretty easy to program in VBA by starting with the first row in the column and iterating through. However, I'm just looking for an excel formula in this case.
I think it will need to be something functionally like:
=INDEX($A$1:$A$100,MATCH(TRUE,($A$1:$A$100)-($A$3:$A$102)<.1,0))
This clearly won't return anything. I'm interested in how to do that subtraction part using excel formulas.
Thanks!
Just need to add the ABS and ARRAY ENTER the formula:
=INDEX($A$1:$A$100,MATCH(TRUE,ABS(($A$1:$A$100)-($A$3:$A$102))<.1,0))
Being an array formula it must be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. If done correctly then Excel will put {} around the formula.

How do I use an array formula over a whole column or varying range?

I have a spreadsheet that I'm importing data into. I need to find the value within a column that is closest to zero. The column contains both positive and negative values, and the value closest to zero will be used in another formula. I've found an answer using an array formula, but it will only work for a fixed range (e.g. K2:K10), and the number of records imported into my sheet will vary each time I use it.
Here's what I have so far:
=INDEX(K:K,MATCH(MIN(ABS(K:K)),ABS(K:K),0))
Is there a way to apply an array formula over an entire column and just include non-zero cells other than the column title? Or possibly just cells with numerical values? Or is it possible to control the range that it applies to?
We can dynamically find the last cell in the range by using another INDEX/MATCH formula that is not an array:
=INDEX(K:K,MATCH(1E+99,K:K))
This will find the last cell that has a number in column K.
So we now use this as the last cell in the range:
=INDEX($K$2:INDEX(K:K,MATCH(1E+99,K:K)),MATCH(MIN(ABS($K$2:INDEX(K:K,MATCH(1E+99,K:K)))),ABS($K$2:INDEX(K:K,MATCH(1E+99,K:K))),0))
And now the formula is dynamic.
This formula is still an array formula and must be confirmed with Ctrl-Shift-Enter when exiting edit mode. If done correctly then Excel will put{} around the formula.
If as you pointed out there is a chance of deleting row 2 then all the K2 references will also be deleted.
In place of K2 we can use INDEX(K:K,2) It will now always look at the second row and will not error when row 2 is erased. So use this instead:
=INDEX(INDEX(K:K,2):INDEX(K:K,MATCH(1E+99,K:K)),MATCH(MIN(ABS(INDEX(K:K,2):INDE‌​X(K:K,MATCH(1E+99,K:K)))),ABS(INDEX(K:K,2):INDEX(K:K,MATCH(1E+99,K:K))),0))
There is nothing wrong with the Offset() function in small amounts, but it is a volatile function. Which means that it will calculate EVERY TIME excel calculate whether the data to which it is dependent has changed or not.
For the benefit of anyone reading this post, I ran into another issue and found a way around it. Scott Craner's answer above worked well until I ran a macro that I had for that sheet, which would delete certain rows. If row 2 got deleted, the formula would give a #REF error, because it was trying to call $K$2.
My solution was to replace $K$2 with
OFFSET(K1,1,0)
Therefore, the complete formula would be:
=INDEX(OFFSET(K1,1,0):INDEX(K:K,MATCH(1E+99,K:K)),MATCH(MIN(ABS(OFFSET(K1,1,0):INDEX(K:K,MATCH(1E+99,K:K)))),ABS(OFFSET(K1,1,0):INDEX(K:K,MATCH(1E+99,K:K))),0))
And as Scott mentioned, remember to hit Ctrl-Shift-Enter to execute the array formula.

Excel: Sumproduct not working when blanks in data set

I am trying to get a sumproduct function to average a column based on criteria in prior adjacent columns.
The column i am trying to average is calculated from a formula that has an IFERROR to return a blank if there is an error.
=IFERROR(A5*B3,"")
some of the cells in that column containt the blank generated by the if error statement, my sumproduct is giving a #value error when it tries to average the range with the blank. I want it treated as nothing not as 0
Is there anyway around this or should I try to recreate my sumproduct using some sort of averageifs function?
This is the sumproduct in question:
=SUMPRODUCT((Data!$KM$7:$OV$7=C$7)*(Data!$KM$9:$OV$118>=$B10)*(Data!$KM$9:$OV$118<=$A10)*(Data!$BLW$9:$BLW$118))/SUMPRODUCT((Data!$KM$7:$OV$7=C$7)*(Data!$KM$9:$OV$118>=$B10)*(Data!$KM$9:$OV$118<=$A10))
Try this array formula instead:
=AVERAGE(IF((Data!$KM$7:$OV$7=C$7)*(Data!$KM$9:$OV$118>=$B10)*(Data!$KM$9:$OV$118<=$A10)*(Data!$BLW$9:$BLW$118<>""),Data!$BLW$9:$BLW$118))
Being an array it needs to be confirmed with Ctrl-Shift-Enter when leaving edit mode. If done properly excel will put {} around the formula.
The reason SUMPRODUCT will not work is it tries to multiply a string, albeit an empty string but a string none the less, with numbers, which will throw an error.
The array formula ignores all the empty string cells and skips them.
The formula =IFERROR(A5*B3,"") puts a "" in the cell. This is not a value, so formulas using this cell won't work. You need to turn it to a numeric value even though it is blank
Use =value(IFERROR(A5*B3,""))
=SUMPRODUCT(P10,M10,L14,L13). This could be easy. We have to write what we want to do rather it is sum, product, division or subtract

Resources