Check whether a cell contains a substring

前端 未结 9 1582
闹比i
闹比i 2020-11-30 17:41

Is there an in-built function to check if a cell contains a given character/substring?

It would mean you can apply textual functions like Left/R

相关标签:
9条回答
  • 2020-11-30 17:51

    This formula seems more intuitive to me:

    =SUBSTITUTE(A1,"SomeText","") <> A1
    

    this returns TRUE if "SomeText" is contained within A1.

    The IsNumber/Search and IsError/Find formulas mentioned in the other answers certainly do work, but I always find myself needing to look at the help or experimenting in Excel too often with those ones.

    0 讨论(0)
  • 2020-11-30 17:57

    Try using this:

    =ISNUMBER(SEARCH("Some Text", A3))
    

    This will return TRUE if cell A3 contains Some Text.

    0 讨论(0)
  • 2020-11-30 17:59

    Here is the formula I'm using

    =IF( ISNUMBER(FIND(".",A1)), LEN(A1) - FIND(".",A1), 0 )

    0 讨论(0)
  • 2020-11-30 18:02

    It's an old question but I think it is still valid.

    Since there is no CONTAINS function, why not declare it in VBA? The code below uses the VBA Instr function, which looks for a substring in a string. It returns 0 when the string is not found.

    Public Function CONTAINS(TextString As String, SubString As String) As Integer
        CONTAINS = InStr(1, TextString, SubString)
    End Function
    
    0 讨论(0)
  • 2020-11-30 18:03

    For those who would like to do this using a single function inside the IF statement, I use

    =IF(COUNTIF(A1,"*TEXT*"),TrueValue,FalseValue)
    

    to see if the substring TEXT is in cell A1

    [NOTE: TEXT needs to have asterisks around it]

    0 讨论(0)
  • 2020-11-30 18:04

    The following formula determines if the text "CHECK" appears in cell C10. If it does not, the result is blank. If it does, the result is the work "CHECK".

    =IF(ISERROR(FIND("CHECK",C10,1)),"","CHECK")
    
    0 讨论(0)
提交回复
热议问题