# If cell begins with x, y, or z

To test values to see if they begin with one of several characters (i.e. begin with x, y, or z) , you can use the COUNTIF function together with the SUM function.

In the example shown, the formula in C5 is:

### How this formula works

The core of this formula is COUNTIF, which is configured to count three separate values using wildcards:

COUNTIF(B5,{"x*","y*","z*"}

The asterisk (*) is a wildcard for one or more characters, so it is used to create a "begins with" test.

The values in the criteria are supplied in an "array constant", a hard-coded list of items with curly braces on either side.

When COUNTIF receives the criteria in an array constant, it will return multiple values, one per item in the list. Because we are only giving COUNTIF a one-cell range, it will only return two possible values for each criteria: 1 or 0.

In cell C5, COUNTIF evaluates to {0,0,0}. In cell C9, COUNTIF evaluates to: {0,1,0}. In each case, the first item is the result of criteria "x*", the second is from criteria "y*", and the third result is from criteria "z*".

Because we are testing for 3 criteria with OR logic, we only care if *any* result is not zero. To check this, we add up all items using the SUM function, and, to force a TRUE/FALSE result, we add ">0" to evaluate the result of SUM. In cell C5, we have:

=SUM({0,0,0})>0

Which evaluates to FALSE.

### More criteria

The example shows 3 criteria (begins with x, y, or z) , but you add more criteria as needed.

### Conditional formatting

Since this formula returns TRUE / FALSE, you can use it as-is to highlight values using conditional formatting.

## Excel Formula Training

Formulas are the key to getting work done in Excel. In this step-by-step training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Start building valuable skills with Excel formulas today. Learn more.