Excel VBA Count Character in Range

This post demonstrates an Excel VBA macro to count the number of instances of a specified character within a range of cells.  The macro prompts the user to input a character, then will loop through each cell and accumulate a count of instances the specified character appears.  The final count is then displayed in a message box.

Excel Version:  2013

OS:  Windows 10

Excel VBA Count Character in Range – Setup

Let’s start with a sample range, something like the following:

Excel VBA Count Character in Range

Next, add the following Excel VBA Macro:

Now, execute the Excel VBA Macro.  First, you will be prompted to input a character:

Excel VBA Count Character in Range

For this example, I will enter “Q” and click OK.

The macro will then initiate a message box, like the following, to inform you how many instances of the character “Q” appear in the range:

Excel VBA Count Character in Range

The search is case sensitive, and requires a single character entry.  Feel free to modify to suit your needs!

 

 

Additional Content

Check out more examples by visiting my Home Page

Here you will find topics covering Qlikview SQL Server Excel VBA

 

 

Leave a Comment