Search code examples
google-sheetsformattingformulaconditional-formatting

Conditional Formatting formula for if cell begins with number list item ("1. ", "2. " etc)


I want to conditional format a few things in my Google Sheet (this applies to excel too though).

Q1: Highlight any cell that begins with a number point.

Such as "1. " or "2. " etc. So 'Number, dot, space'. My working formula currently is:

=OR(LEFT(C1,3) = "1. ", LEFT(C1,3) = "2. ", LEFT(C1,3) = "3. ", LEFT(C1,3) = "4. ", LEFT(C1,3) = "5. ")

But I'm sure there's a REGEX way of doing this, right? Instead of manually doing an OR condition for each number? (The length is unknown, I just stopped at 5 in the formula for an example).


Q2: Formatting any of a list of strings

How can I detect if the cell 'starts with' (or 'is exactly') either "Apples", "Oranges", or "Mangos". Something like:

=OR(C1={"Apples", "Oranges", "Mangos"})

The above is only ever highlighting the first in that list, regardless of if its Apples or Oranges etc.

Thoughts?


Solution

  • Please try the following in custom formula is

    =REGEXMATCH(G2,"^\d+. ")

    enter image description here

    (do adjust ranges to your needs)