SOLVED

How To Check If Column has Certain Word

%3CLINGO-SUB%20id%3D%22lingo-sub-1696719%22%20slang%3D%22en-US%22%3EHow%20To%20Check%20If%20Column%20has%20Certain%20Word%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1696719%22%20slang%3D%22en-US%22%3E%3CP%3EHello.%20In%20excel%2C%20I%20have%20a%20cell%20that%20is%20supposed%20to%20check%20if%20the%20word%20in%20a%20box%20matches%20one%20of%20the%20words%20in%20the%20A%20column.%20However%2C%20when%20I%20try%20running%20it%2C%20it%20says%20%23SPILL!%20The%20function%20is%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DIF(FIND(F6%2CA%3AA)%26gt%3B-1%2C%20%22Hello%22%2C%20B1)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EF6%20is%20the%20input%2C%20A%20is%20the%20column%20where%20the%20words%20are%20being%20stored%2C%20B1%20is%20a%20null%2C%20so%20that%20if%20it%20doesn't%20match%2C%20it%20shows%20a%200%2C%20which%20will%20be%20changed%20later.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHowever%2C%20when%20I%20run%20it%2C%20it%20displays%20as%20%23SPILL!%3C%2FP%3E%3CP%3EDoes%20anybody%20know%20what%20the%20problem%20might%20be%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1696719%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1700528%22%20slang%3D%22en-US%22%3ERe%3A%20How%20To%20Check%20If%20Column%20has%20Certain%20Word%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1700528%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F802023%22%20target%3D%22_blank%22%3E%40HaveProblemsEveryday%3C%2FA%3E%26nbsp%3B%2C%20you%20are%20welcome%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1700123%22%20slang%3D%22en-US%22%3ERe%3A%20How%20To%20Check%20If%20Column%20has%20Certain%20Word%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1700123%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3BThank%20you%2C%20this%20ended%20up%20working%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1698451%22%20slang%3D%22en-US%22%3ERe%3A%20How%20To%20Check%20If%20Column%20has%20Certain%20Word%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1698451%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F802023%22%20target%3D%22_blank%22%3E%40HaveProblemsEveryday%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnother%20variant%20is%20to%20use%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DIF(SUM(COUNTIF(F6%2CA%3AA))%2C%22Hello%22%2CB1)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Ebut%20from%20performance%20point%20of%20view%20much%20better%20to%20use%20dynamic%20range%20as%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DIF(SUM(COUNTIF(F6%2CA1%3AINDEX(A%3AA%2CCOUNTA(A%3AA))))%2C%22Hello%22%2CB1)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1698171%22%20slang%3D%22en-US%22%3ERe%3A%20How%20To%20Check%20If%20Column%20has%20Certain%20Word%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1698171%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F802023%22%20target%3D%22_blank%22%3E%40HaveProblemsEveryday%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20your%20formula%2C%20Excel%20tries%20to%20find%20the%20text%20string%20from%20F6%20in%20%3CSTRONG%3Eevery%26nbsp%3Bcell%3C%2FSTRONG%3E%20in%20column%20A%20(i.e.%201048576%20cells)%20and%20output%20the%20result%20(a%20number%20if%20found%20and%20%23VALUE!%20if%20not%20found)%20for%20each%20of%20these%20in%20one%20single%20(dynamic)%20array.%20If%20you%20have%20that%20formula%20in%20any%20other%20place%20than%20on%20the%20first%20row%2C%20the%20%23SPILL!%20error%20appears%20as%20there%20isn't%20enough%20space%20to%20display%20the%20entire%20results-array%20containing%201048576%20cells.%20To%20demonstrate%2C%20I've%20limited%20the%20%22find%20area%22%20to%20A1%3AA10%20in%20the%20example%20below%20(picture).%20As%20you%20can%20see%2C%20your%20formula%20will%20return%20%22Hello%22%20somewhere%20in%20the%20output%20array%20if%20the%20word%20%22Car%22%20is%20found.%20All%20other%20cells%20will%20contain%20%23VALUE!%20.%20So%2C%20is%20doesn't%20produce%20a%20single%20cell%20output%20with%20the%20word%20%22Hello%22%20of%20a%20null.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Screenshot%202020-09-22%20at%2006.31.28.png%22%20style%3D%22width%3A%20336px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F220845iA2ACD770FC9AFC83%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22Screenshot%202020-09-22%20at%2006.31.28.png%22%20alt%3D%22Screenshot%202020-09-22%20at%2006.31.28.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETo%20get%20a%20singe%20cell%20result%2C%20try%20it%20this%20way%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DIF(SUM(IFERROR(FIND(F6%2CA%3AA)%2C0))%26gt%3B0%2C%22Hello%22%2CB1)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EThis%20formula%20will%20find%20all%20occurrences%20of%20the%20word%20to%20find%2C%20replace%20errors%20with%20zeros%2C%20sum%20the%20entire%20array%20and%20if%20the%20result%20is%20greater%20than%20zero%20(meaning%20that%20some%20match%20was%20found)%2C%20return%20%22Hello%22%20else%20B1.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20you%20should%20be%20aware%20that%20FIND%20looks%20for%20a%20text%20string%20within%20other%20text%20strings%20and%20it%20is%20case%20sensitive.%20So%2C%20if%20the%20word%20in%20F6%20contains%20%22Car%22%20and%20column%20A%20contains%20the%20word%20%22Card%22%20you%20will%20get%20a%20positive%20(%22Hello%22)%20result.%20If%20column%20A%2C%20on%20the%20other%20hand%2C%20contains%20the%20word%20%22car%22%2C%20you%20will%20get%20your%20null%20result.%20If%20that's%20really%20what%20you%20want%20you're%20set%20to%20go.%20If%20you%20want%20to%20find%20text%20strings%20that%20are%20not%20case%20sensitive%20use%20SEARCH.%20If%20you%20want%20to%20find%20an%20exact%20match%20of%20a%20word%20use%20MATCH.%20Then%20it%20could%20look%20like%20this%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DIF(ISNUMBER(MATCH(F6%2CA%3AA%2C0))%2C%22Hello%22%2CB1)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hello. In excel, I have a cell that is supposed to check if the word in a box matches one of the words in the A column. However, when I try running it, it says #SPILL! The function is:

 

=IF(FIND(F6,A:A)>-1, "Hello", B1)

 

F6 is the input, A is the column where the words are being stored, B1 is a null, so that if it doesn't match, it shows a 0, which will be changed later.

 

However, when I run it, it displays as #SPILL!

Does anybody know what the problem might be?

4 Replies

@HaveProblemsEveryday 

In your formula, Excel tries to find the text string from F6 in every cell in column A (i.e. 1048576 cells) and output the result (a number if found and #VALUE! if not found) for each of these in one single (dynamic) array. If you have that formula in any other place than on the first row, the #SPILL! error appears as there isn't enough space to display the entire results-array containing 1048576 cells. To demonstrate, I've limited the "find area" to A1:A10 in the example below (picture). As you can see, your formula will return "Hello" somewhere in the output array if the word "Car" is found. All other cells will contain #VALUE! . So, is doesn't produce a single cell output with the word "Hello" of a null.

Screenshot 2020-09-22 at 06.31.28.png

 

To get a singe cell result, try it this way:

=IF(SUM(IFERROR(FIND(F6,A:A),0))>0,"Hello",B1)

This formula will find all occurrences of the word to find, replace errors with zeros, sum the entire array and if the result is greater than zero (meaning that some match was found), return "Hello" else B1.

 

But you should be aware that FIND looks for a text string within other text strings and it is case sensitive. So, if the word in F6 contains "Car" and column A contains the word "Card" you will get a positive ("Hello") result. If column A, on the other hand, contains the word "car", you will get your null result. If that's really what you want you're set to go. If you want to find text strings that are not case sensitive use SEARCH. If you want to find an exact match of a word use MATCH. Then it could look like this:

=IF(ISNUMBER(MATCH(F6,A:A,0)),"Hello",B1)

 

best response confirmed by HaveProblemsEveryday (Occasional Contributor)
Solution

@HaveProblemsEveryday 

Another variant is to use

=IF(SUM(COUNTIF(F6,A:A)),"Hello",B1)

but from performance point of view much better to use dynamic range as

=IF(SUM(COUNTIF(F6,A1:INDEX(A:A,COUNTA(A:A)))),"Hello",B1)

 

@Sergei Baklan Thank you, this ended up working

@HaveProblemsEveryday , you are welcome