Search code examples
excelexcel-formulaconditional-formatting

Search number in string, distinguish number of digits


The user enters a formula as a string in cell B1 using some of the variables in cells A1:A16. I want to create a conditional formatting rule to highlight the variables used.

enter image description here

I used this which works fine for c1 to c9. As you can see in the picture, it doesn't work for c16 because it highlights both c1 and c16.

=ISNUMBER(SEARCH(A1,$B$1))

Solution

  • As commented above, the formula given in the first comment will not work with Conditional Formatting, since reference operators can't be used within Conditional Formatting. Hence create a range of those operators and use the formula in Conditional Formatting.


    enter image description here


    • Formula used in conditional formatting:

    =XMATCH(A1:A16,TEXTSPLIT($B$1,$F$2:$F$11))
    

    Where F2:F11

    Operators
    #
    $
    (
    )
    *
    +
    -
    /
    =
    @

    Here is another example.

    enter image description here