SOLVED

Find a list of words in multiple columns

%3CLINGO-SUB%20id%3D%22lingo-sub-1749339%22%20slang%3D%22en-US%22%3EFind%20a%20list%20of%20words%20in%20multiple%20columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1749339%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%20please%2C%20I%20use%20this%20formula%20in%20Excel%20to%20find%20out%20which%20cells%20contain%20certain%20text%3A%3C%2FP%3E%3CP%3E%3DIF(COUNT(SEARCH(%7B%22white%22%2C%22blue%22%2C%22red%22%2C%22black%22%7D%2CB1))%2C%22Yes%22%2C%22%22)%3C%2FP%3E%3CP%3EAs%20you%20can%20see%2C%20the%20formula%20looks%20for%20text%20in%20cell%20B1.%20How%20to%20extend%20the%20search%20field%20to%20the%20range%20of%20cells%20A1%3AAQ1%3F%26nbsp%3BBecause%20when%20I%20write%20A1%3AAQ1%20there%2C%20it%20looks%20like%20nothing%20was%20found.%20Thank%20you%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1749339%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1749522%22%20slang%3D%22en-US%22%3ERe%3A%20Find%20a%20list%20of%20words%20in%20multiple%20columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1749522%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F729591%22%20target%3D%22_blank%22%3E%40temporalnaut%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETry%20this%20formula%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3DIF(SUM(COUNTIF(A1%3AQ1%2C%7B%22*white*%22%2C%22*blue*%22%2C%22*red*%22%2C%22*black*%22%7D))%2C%22Yes%22%2C%22%22)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1749563%22%20slang%3D%22en-US%22%3ERe%3A%20Find%20a%20list%20of%20words%20in%20multiple%20columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1749563%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%3E%40Hans%20Vogelaar%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CDIV%20class%3D%22lia-message-body%20lia-component-message-view-widget-body%20lia-component-body-signature-highlight-escalation%20lia-component-message-view-widget-body-signature-highlight-escalation%22%3E%3CDIV%20class%3D%22lia-message-body-content%22%3E%3CP%3EIt%20works.%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3A)Would%20it%20be%20possible%20to%20select%20specific%20cells%20instead%20of%20the%20whole%20range%20of%20cells%3F%3C%2FP%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1749644%22%20slang%3D%22en-US%22%3ERe%3A%20Find%20a%20list%20of%20words%20in%20multiple%20columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1749644%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F729591%22%20target%3D%22_blank%22%3E%40temporalnaut%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EJust%20for%20some%20random%20cells%2C%20or%20do%20they%20have%20a%20pattern%2C%20for%20example%20every%20other%20or%20every%20third%20cell%20in%20A1%3AQ1%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1749648%22%20slang%3D%22de-DE%22%3ESubject%3A%20Find%20a%20list%20of%20words%20in%20multiple%20columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1749648%22%20slang%3D%22de-DE%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F729591%22%20target%3D%22_blank%22%3E%40temporalnaut%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22tlid-translation%20translation%22%3E%3CSPAN%20class%3D%22%22%3EIn%20addition%20to%20the%20actually%20best%20solution%20that%20Mr.%3C%2FSPAN%3E%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3EHans%20Vogelaar%20(%40Hans%20Vogelaar)%20%3C%2FA%3E%3CSPAN%20class%3D%22tlid-translation%20translation%22%3E%20%3CSPAN%20class%3D%22%22%3Eoffered%20you%2C%20this%20information.%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3EBut%20could%20also%20use%20Mr.%3C%2FSPAN%3E%3C%2FSPAN%3E%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3EHans%20Vogelaar%20(%40Hans%20Vogelaar)%20%3C%2FA%3E%20%3CSPAN%20class%3D%22tlid-translation%20translation%22%3E%3CSPAN%20class%3D%22%22%3Eformula%2C%20just%20need%20to%20set%20the%20area%20to%20a%20specific%20cell.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CH1%20id%3D%22toc-hId-556225162%22%20id%3D%22toc-hId-556225162%22%20id%3D%22toc-hId-556225162%22%20id%3D%22toc-hId-556225162%22%20id%3D%22toc-hId-556225162%22%20id%3D%22toc-hId-556225162%22%20id%3D%22toc-hId-556225162%22%20id%3D%22toc-hId-556225162%22%3E%3CFONT%20size%3D%223%22%3ECheck%20if%20a%20cell%20contains%20text%20(case-insensitive)%3C%2FFONT%3E%3C%2FH1%3E%3CP%3E%3CFONT%20size%3D%223%22%3E%3CA%20href%3D%22https%3A%2F%2Fsupport.microsoft.com%2Fen-us%2Foffice%2Fcheck-if-a-cell-contains-text-case-insensitive-7bb505c7-2815-4a7a-9544-57a5f0dcd551%3Fui%3Den-us%26amp%3Brs%3Den-us%26amp%3Bad%3Dus%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fsupport.microsoft.com%2Fen-us%2Foffice%2Fcheck-if-a-cell-contains-text-case-insensitive-7bb505c7-2815-4a7a-9544-57a5f0dcd551%3Fui%3Den-us%26amp%3Brs%3Den-us%26amp%3Bad%3Dus%3C%2FA%3E%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENikolino%3C%2FP%3E%3CP%3EI%20know%20I%20don't%20know%20anything%20(Socrates)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1750124%22%20slang%3D%22en-US%22%3ERe%3A%20Find%20a%20list%20of%20words%20in%20multiple%20columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1750124%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%3E%40Hans%20Vogelaar%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWithout%20a%20pattern.%20I%20need%20to%20choose%20this%2C%20this%20and%20this%20cell%20(and%20then%2C%20of%20course%2C%20after%20dragging%20the%20formula%20to%20the%20next%20row%2C%20the%20values%20corresponding%20to%20the%20respective%20row%20are%20recalculated).%3CBR%20%2F%3EI%20have%20two%20more%20questions%3A%3CBR%20%2F%3E1)%20how%20to%20modify%20this%20formula%20or%20what%20formula%20should%20be%20used%20to%20display%20the%20text%20(s)%20it%20found%20instead%20of%20%22Yes%22%20(the%20mark%20that%20the%20cell%20contains%20the%20found%20text).%3CBR%20%2F%3E2)%20how%20to%20search%20only%20for%20whole%20specific%20words%20(not%20parts%20of%20other%20words%2C%20eg%20%22bluegrass%22%20to%20ignore%20when%20searching%20for%20blue)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1750823%22%20slang%3D%22en-US%22%3ERe%3A%20Find%20a%20list%20of%20words%20in%20multiple%20columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1750823%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F729591%22%20target%3D%22_blank%22%3E%40temporalnaut%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThat%20is%20much%20more%20complicated.%20The%20only%20way%20I%20can%20think%20of%20is%20to%20store%20the%20list%20of%20colors%20in%20a%20range%2C%20and%20to%20use%20a%20custom%20VBA%20function%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-visual%22%3E%3CCODE%3EFunction%20FindText(rng%20As%20Range%2C%20ParamArray%20args())%20As%20String%0A%20%20%20%20Dim%20c%20As%20Variant%0A%20%20%20%20Dim%20c1%20As%20Range%0A%20%20%20%20Dim%20w%20As%20Variant%0A%20%20%20%20Dim%20s%20As%20String%0A%20%20%20%20Dim%20v%20As%20String%0A%20%20%20%20For%20Each%20c%20In%20args%0A%20%20%20%20%20%20%20%20If%20TypeName(c)%20%3D%20%22Range%22%20Then%0A%20%20%20%20%20%20%20%20%20%20%20%20For%20Each%20c1%20In%20c%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20v%20%3D%20%22%20%22%20%26amp%3B%20c1.Value%20%26amp%3B%20%22%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20For%20Each%20w%20In%20rng%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20If%20InStr(1%2C%20v%2C%20%22%20%22%20%26amp%3B%20w.Value%20%26amp%3B%20%22%20%22%2C%20vbTextCompare)%20Then%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20s%20%3D%20s%20%26amp%3B%20vbLf%20%26amp%3B%20Trim(v)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Exit%20For%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20End%20If%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Next%20w%0A%20%20%20%20%20%20%20%20%20%20%20%20Next%20c1%0A%20%20%20%20%20%20%20%20Else%0A%20%20%20%20%20%20%20%20%20%20%20%20v%20%3D%20%22%20%22%20%26amp%3B%20c%20%26amp%3B%20%22%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20For%20Each%20w%20In%20rng%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20If%20InStr(1%2C%20v%2C%20%22%20%22%20%26amp%3B%20w.Value%20%26amp%3B%20%22%20%22%2C%20vbTextCompare)%20Then%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20s%20%3D%20s%20%26amp%3B%20vbLf%20%26amp%3B%20Trim(v)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Exit%20For%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20End%20If%0A%20%20%20%20%20%20%20%20%20%20%20%20Next%20w%0A%20%20%20%20%20%20%20%20End%20If%0A%20%20%20%20Next%20c%0A%20%20%20%20If%20s%20%26lt%3B%26gt%3B%20%22%22%20Then%0A%20%20%20%20%20%20%20%20FindText%20%3D%20Mid(s%2C%202)%0A%20%20%20%20End%20If%0AEnd%20Function%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELet's%20say%20that%20you%20entered%20the%20words%20%3CSTRONG%3Ewhite%3C%2FSTRONG%3E%2C%20%3CSTRONG%3Eblue%3C%2FSTRONG%3E%2C%20%3CSTRONG%3Ered%3C%2FSTRONG%3E%20and%20%3CSTRONG%3Eblack%3C%2FSTRONG%3E%20in%20A3%3AA6%2C%20and%20that%20you%20want%20to%20return%20the%20values%20of%20the%20cell(s)%20in%20A1%2C%20C1%2C%20F1%2C%20H1%3AK2%2C%20D2%20and%20L1%3AP1%20that%20contain%20at%20least%20one%20of%20those%20words%20(matching%20whole%20words%20only).%3C%2FP%3E%0A%3CP%3EThe%20formula%20would%20be%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3DFindText(A3%3AA6%2CA1%2CC1%2CF1%2CH1%3AK2%2CD2%2CL1%3AP1)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETurn%20on%20Wrap%20Text%20for%20the%20cell%20with%20the%20formula.%3C%2FP%3E%0A%3CP%3EMake%20sure%20that%20you%20save%20the%20workbook%20as%20a%20macro-enabled%20workbook%20(.xlsm)%20and%20that%20you%20allow%20macros%20when%20you%20open%20the%20workbook.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1751216%22%20slang%3D%22en-US%22%3ERe%3A%20Find%20a%20list%20of%20words%20in%20multiple%20columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1751216%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F729591%22%20target%3D%22_blank%22%3E%40temporalnaut%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20solution%20uses%20the%20Excel%20365%20function%20LET%20to%20organise%20the%20solution%20but%20defined%20names%20or%20substituting%20the%20local%20variables%20out%20to%20get%20a%20single%20nested%20formula%20would%20work%20as%20well%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3D%20LET(%0A%20%20words%2C%20%7B%22white%22%3B%22blue%22%3B%22red%22%3B%22black%22%7D%2C%0A%20%20matrix%2C%20SIGN(ISNUMBER(SEARCH(words%2Carray)))%2C%0A%20%20sum%2C%20MMULT(%7B1%2C1%2C1%2C1%7D%2C%20matrix)%2C%0A%20%20IF(sum%2C%22Yes%22%2C%22-%22)%20)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOnly%20the%20first%20and%20last%20rows%20in%20the%20image%20are%20needed%2C%20the%20rest%20serves%20as%20explanation%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20696px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F224662i2E292D8BB647FC0F%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Contributor

Hi, please, I use this formula in Excel to find out which cells contain certain text:

=IF(COUNT(SEARCH({"white","blue","red","black"},B1)),"Yes","")

As you can see, the formula looks for text in cell B1. How to extend the search field to the range of cells A1:AQ1? Because when I write A1:AQ1 there, it looks like nothing was found. Thank you

8 Replies
Highlighted
Best Response confirmed by allyreckerman (Microsoft)
Solution

@temporalnaut 

Try this formula:

 

=IF(SUM(COUNTIF(A1:Q1,{"*white*","*blue*","*red*","*black*"})),"Yes","")

Highlighted

@Hans Vogelaar 

It works. Would it be possible to select specific cells instead of the whole range of cells?

Highlighted

@temporalnaut 

Just for some random cells, or do they have a pattern, for example every other or every third cell in A1:Q1?

Highlighted

@temporalnaut 

 

In addition to the actually best solution that Mr.Hans Vogelaar (@Hans Vogelaar) offered you, this information. But could also use Mr. Hans Vogelaar (@Hans Vogelaar) formula, just need to set the area to a specific cell.

Check if a cell contains text (case-insensitive)

https://support.microsoft.com/en-us/office/check-if-a-cell-contains-text-case-insensitive-7bb505c7-2...

 

Nikolino

I know I don't know anything (Socrates)

Highlighted

@Hans Vogelaar 

Without a pattern. I need to choose this, this and this cell (and then, of course, after dragging the formula to the next row, the values ​​corresponding to the respective row are recalculated).
I have two more questions:
1) how to modify this formula or what formula should be used to display the text (s) it found instead of "Yes" (the mark that the cell contains the found text).
2) how to search only for whole specific words (not parts of other words, eg "bluegrass" to ignore when searching for blue)

Highlighted

@temporalnaut 

That is much more complicated. The only way I can think of is to store the list of colors in a range, and to use a custom VBA function:

 

Function FindText(rng As Range, ParamArray args()) As String
    Dim c As Variant
    Dim c1 As Range
    Dim w As Variant
    Dim s As String
    Dim v As String
    For Each c In args
        If TypeName(c) = "Range" Then
            For Each c1 In c
                v = " " & c1.Value & " "
                For Each w In rng
                    If InStr(1, v, " " & w.Value & " ", vbTextCompare) Then
                        s = s & vbLf & Trim(v)
                        Exit For
                    End If
                Next w
            Next c1
        Else
            v = " " & c & " "
            For Each w In rng
                If InStr(1, v, " " & w.Value & " ", vbTextCompare) Then
                    s = s & vbLf & Trim(v)
                    Exit For
                End If
            Next w
        End If
    Next c
    If s <> "" Then
        FindText = Mid(s, 2)
    End If
End Function

 

Let's say that you entered the words white, blue, red and black in A3:A6, and that you want to return the values of the cell(s) in A1, C1, F1, H1:K2, D2 and L1:P1 that contain at least one of those words (matching whole words only).

The formula would be

 

=FindText(A3:A6,A1,C1,F1,H1:K2,D2,L1:P1)

 

Turn on Wrap Text for the cell with the formula.

Make sure that you save the workbook as a macro-enabled workbook (.xlsm) and that you allow macros when you open the workbook.

Highlighted

@temporalnaut 

This solution uses the Excel 365 function LET to organise the solution but defined names or substituting the local variables out to get a single nested formula would work as well:

 

= LET(
  words, {"white";"blue";"red";"black"},
  matrix, SIGN(ISNUMBER(SEARCH(words,array))),
  sum, MMULT({1,1,1,1}, matrix),
  IF(sum,"Yes","-") )

 

Only the first and last rows in the image are needed, the rest serves as explanation

image.png

Highlighted

thank you all for help