This post will guide you how to** count the number of cells that end with a specific value **within a range of cells using a formula in Excel 2013/2016 or Excel office 365. How do I count cells that end with a specific text through the use of VBA Macro in Excel.

## Count Number of Cells that End with a Specific Text Through Formula

If you want to count the number of cells that end with a specific text value “**el**” in range B1:B6, and you can use the COUNTIF function to build a formula. And you need to use the asterisk**(*)** sign to count the number of cells that end with “**el**”. Just using the following formula:

**=COUNTIF(B1:B6,”*ex”)**

**LET’S SEE THAT HOW THIS FORMULA WORKS:**

The COUNTIF function can be used to count the number of cells in the range that end with a specific text by matching the content of each cell against the pattern. And the asterisk sign is a wildcard that means “match any number of characters”.

## Count Number of Cells that End with a Specific Text Through VBA

You can also use an VBA Macro to count cells if ends with a specific value in Excel. Just do the following steps:

**Step1#** open your excel workbook and then click on “**Visual Basic**” command under **DEVELOPER** Tab, or just press “**ALT+F11**” shortcut.

**Step2#** then the “Visual Basic Editor” window will appear.

**Step3# **click “**Insert**” ->”**Module**” to create a new module.

**Step4# **paste the below VBA code into the code window. Then clicking “**Save**” button.

Sub CountCellsEndWith()
Dim ws As Worksheet
Set ws = Worksheets("Sheet3")
ws.Range("D1") = Application.WorksheetFunction.CountIf(ws.Range("B1:B6"), "*" & "el")
End Sub

**Note:** you need to change the output range D1 to place the final result. And change the data range that you want to test the criteria against by changing the cell reference. You also need to change “el” pattern as you need .

**Step5#** back to the current worksheet, click on `Macros`

button under `Code`

group. then click `Run`

button.

**Step6#** let’s see the result:

### Related Functions

- 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

Filter And Transpose Data From Horizontal To Vertical
This post will show you how to use Filter function and in combination with Transpose function to filter data from horizontal and transpose data as vertical in Microsoft Excel. You can refer to the below general formula based on TRANSPOSE ...

VLOOKUP Formula | Faster Trick with 2 VLOOKUPS
This post will guide you how to use 2 VLOOKUPS function to looking up data entries from a given range of cells in Microsoft Excel. VLOOKUP with 2 lookups can be faster than a single VLOOKUP in certain scenarios. The ...

Extract Unique Items From A List
This post will guide you how to extract unique itmes from a given list in Microsoft Excel. How to create a newly formula to get unique values from a range cells in Excel. The unique list of items is the ...

Extract substring In Excel
This post will guide you how to use Excel's MID function is a quick and easy way to extract pieces from your text. Use the Excel formula to extract a substring with MID. Note: If you want to extract just ...

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 ...

Extract all the matches with helper Column
With Excel's powerful functions IF, INDEX, and MATCH, we can find exactly what you're looking for with a few clicks of the mouse. This step-by-step tutorial will show how easy it is to extract data using these tools and more! ...

If Cell is This Value or That Value
IF function is frequently used in Excel worksheet to return you expect “true value” or “false value” based on the result of logical test. If you want to see if a cell is A or B, and if one of ...

If Value is Greater Than A Certain Value
IF function is frequently used in Excel worksheet to return you expect “true value” or “false value” based on the logical test result. If you want to see if a value in one cell is greater than a specific value, ...

If Cell is Not Blank
IF function is frequently used in Excel worksheet to return you expect “true value” or “false value” based on the result of created logical test. If you want to see if a cell is blank or not, and leave some ...

VBA Macro For VLOOKUP From Another Sheet
In the previous post, you should know that how to fix or remove the #N/A error when using VLOOKUP formula to lookup value from another sheet. And this post will show you how to use VBA code to vlookup data ...