# If Cell Begins with One of Three Supplied Characters

If you want to test values to see if they begin with some given specific characters like “x”, ”y”, or “z”, you can create a formula with COUNTIF and SUM functions to return results.

## EXAMPLE You can see “TRUE” or “FALSE” is returned properly based on the first letter in each cell.

In this example, we supply three letters “x”, “y” and “z” as the conditions of “begins with”, if texts begin with one of them, we will get “TRUE” after running the formula. If texts begin with other letters, “FALSE” is displayed after running the formula.

## FORMULA

Refer to above example, the generic formula is:

=SUM(COUNTIF(A1, “X*”, “Y*”, “Z*”))>0

## FORMULA EXPLANATION

COUNTIF is used for counting the numbers of values from a range or an array that meet a specified condition.

Syntax: COUNTIF(Range, Criteria).

In Excel formula, we use “X*” to represent a value begins with “X”, the asterisk (*) is a wildcard to stand for one or more characters. So, values like “X”, “Xe” or “Xee” all meet the condition “begins with “X*””.

As we supply three letters “x”, “y”, “z” in this example, so we create an array constant {“x*”,”y*”,”z*”} to show the collection of criteria “begins with”. As the three letters are given as a precondition, so they are hard-coded, we use comma to separate them. An array constant is started with curly brace and ended with curly brace.

COUNTIF function compares text in cell with the items in array constant one by one. In this COUNTIF, as there is only one cell in range, and text can only begins with one of the three supplied letters or none of them, thus COUNTIF(A2,{“x*”,”y*”,”z*”}) can only returns “1” or “0” for each criteria after comparing with text in A2.

For example, in cell A2, text is “zje”, in array constant the first item is “x*”, obviously “zje” doesn’t meet the criteria, “0” is returned and saved in array, COUNTIF retrieves the next criteria “y*” to compare with “zje”, still returns “0”, and for the last criteria “z*”, “1” is returned.

In this example, we can get different results after running COUNTIF:

COUNTIF(A2,{“x*”,”y*”,”z*”})->COUNTIF(“zje”,{“x*”,”y*”,”z*”})->{0,0,1}

COUNTIF(A3,{“x*”,”y*”,”z*”}))>COUNTIF(“abc”,{“x*”,”y*”,”z*”})->{0,0,0}

After explanation, we can see there are only four results returned by COUNTIF: {0,0,1}, {1,0,0}, {0,1,0} and {0,0,0}. They are returned by COUNTIF and delivered to SUM function directly. SUM function then add up all items in the list, there are only two results “1” and “0”. We add “>0” after SUM() to compare SUM result with 0 and force result to “TRUE” of “FALSE”; if result is greater than 0, “TRUE” is the final result of SUM(COUNTIF())>0; if SUM result is 0, logical test fails, so “FALSE” is the final result.

## COMMENT

1. You can add more criteria per your demands if you have multiple criteria.
2. It doesn’t require an exact match and is case-insensitive when comparing with text and criteria.
3. To get “TRUE” or “FALSE” as final result, you can add logical test “>0” to force SUM evaluates to “TRUE” or “FALSE”.

### Related Functions

• Excel SUM function
The Excel SUM function will adds all numbers in a range of cells and returns the sum of these values. You can add individual values, cell references or ranges in excel.The syntax of the SUM function is as below:= SUM(number1,[number2],…)…
• Excel COUNTIF function
The Excel COUNTIF function will count the number of cells in a range that meet a given criteria. This function can be used to count the different kinds of cells with number, date, text values, blank, non-blanks, or containing specific characters.etc.= COUNTIF (range, criteria)…
Related Posts

6 Best Free Wedding Budget Templates

This post will show you some free wedding budget spreadsheet templates for both google sheets and Microsoft Excel Spreadsheet, as well as some explanations of the features or important function points of these templates. You can then easily make modifications ...

Calculate Cumulative Totals with Excel SUM Function

Today, through a simple example, we will show you how to use one of the most common-used Mathematical functions in excel, the SUM function, to add up the sum. In our daily life, we keep an account of what we ...

Check Dates in chronological order

Assume you have a date list that has different date formats, as seen in the accompanying picture. In this instance, Excel's Sort function will fail to sort them appropriately. However, you may convert all various date formats to a particular ...

How to Use 3D SUM Multiple Worksheets

To sum a range of numbers is straightforward for most Excel users, but do you know how to establish a 3D reference to total the same range of numerous sheets. In this post, I will present the steps for this ...

Average per Week by Formula in Excel

We usually apply AVERAGE function or relevant functions to return average directly in Excel worksheet. But in some situations, only applying average relevant functions cannot figure out our problem. Sometimes we can create a formula with functions and mathematical operation ...

How to Sum if Contains an Asterisk

To add numbers together we need to apply SUM function. And if we want to add numbers based on some conditions, we can add criteria with the help of SUMIFS function, SUMIFS can filter data with multiple criteria effectively. If ...

How to Sum in Vertical Range

If we want to add numbers based on some conditions in Excel worksheet, we can add criteria with the help of SUMIFS function, SUMIFS can filter data with multiple criteria effectively. In this article, we will introduce you the method ...

How to Sum in Horizontal Range

To add numbers together we need to apply SUM function. But if we want to add numbers based on some conditions, we can add criteria with the help of SUMIFS function, SUMIFS can filter data with multiple criteria effectively. In ...

How to Sum with Criteria and Or Logic in Excel

To add numbers together we need to apply SUM function. And if we want to add numbers based on some conditions, we can add criteria with the help of SUMIFS function, SUMIFS can filter data with multiple criteria effectively. If ...

How To Sum the Largest N Values in Excel

Sometimes we may want to sum the largest N numbers or top N numbers in a range. In this article, we will show you the method of “SUM the Largest N Numbers” by a simple formula which consist of SUMPRODUCT ...

Sidebar