# Excel Formulas - Count number of cells ends with string

## Count number of cells ends with a specific string

Syntax of used function(s)

```COUNTIF(criteria_range, criteria)
```

The COUNTIF function is used to count the number of cells that meet a certain criteria.

Explanation

To count the number of cells that contain a text ends with '01', the COUNTIF function can be used.

Formula

``````
=COUNTIF(B5:B11,"*01")

``````

How the formula works

In the above example the COUNTIF function searth in the range of cell B5:B11 which contain the text that ends with '01' and counts.

## Count number of cells ends with string using range name and criteria range

Explanation

To count number of cells from a range of cells assigned by a range name, which contain the text ends with a specific text written in a criteria variable.

Formula

``````
=COUNTIF(Invoice_No,D9)

``````

How the formula works

In the above example the COUNTIF function search the criteria variable D9 which contain the criteria value in the range name "Invoice_No" and counts.

The criteria variable contain the value "*_????", it means that, the last four characters may be any character, the 5th last character must be underscore character(_) and the remaining may be any characters.

﻿