# Count number of times a specific text appears in a string & range

#### Rav_Singh

##### New Member
I hope someone can help with this problem I am failing to find a solution for.

I wish to count the number of times a specific text value appears in a range. The text itself will often be part of a string which will contain other information.

Below is an example of the issue I am encountering... In this instance but not exclusive I am trying to locate the number of times 'Accounting' appears in a range.

Example (value):
[Cell B1] Accounting

Example (Range):
[Cell A1] Accounting
[Cell A2] Accounting OR Business+services
[Cell A3] Accounts OR Accounting

Solution:
[Cell C1] 3

I had hoped the below formulas would work but alas these only return 1 instead of 3.

=SUMPRODUCT((--EXACT(B1,A1:A3))) = 1
=COUNTIF(A1:A3,B1) = 1

* If possible I would appreciate a solution which includes the cell (in this case 'B1') in the formula rather than 'Accounting' as this solution is intended to incorporate other values.

As always any feedback will be greatly received and appreciated.

Last edited:

#### kweaver

##### Well-known Member
Have you tried this in C1 with the word you're searching for in B1:

Code:
``=COUNTIF(A1:A100,"*"&B1&"*")``

#### gaz_chops

##### Well-known Member
Try

=SUM(--ISNUMBER(FIND(B1,A1:A3)))

enter as an array with Ctrl, Shift Enter

#### Rav_Singh

##### New Member
Thank you both for taking time out to post your input.

I was worried this solution was too good to be true and alas it has proved so.

I have updated the scenario below to provide the complexity of the issue.

Example (value):
[Cell B1] Accounting

Example (Range):
[Cell A1] Accounting
[Cell A2] Accounting OR Business+services
[Cell A3] Accounts OR Accounting
[Cell A4] Accounting+Department *(Do not count this in the solution)
[Cell A5] Director+of+Accounting *(Do not count this in the solution)

Solution:
[Cell C1] 3

Any further input will be greatly received.

Last edited:

#### kweaver

##### Well-known Member
Are you saying that if there's a * in the cell, not to consider this in the count?

#### gaz_chops

##### Well-known Member
What is the criteria whereby the search value is counted, or not?

#### Rav_Singh

##### New Member
To clarify '*(Do not count this in the solution) ' is not part of the string/range. This was my attempt to indicate that the text in cells A4 & A5 should not be calculated in the solution.

Thanks.

#### Fluff

##### MrExcel MVP, Moderator
Judging by post#4
Maybe

#### Rav_Singh

##### New Member
Job done! - Take a bow.

I always say this on here but many thanks for all contributors taking time out to assist with my Excel issues!

Judging by post#4
Maybe

ABC
1AccountingAccounting3
3Accounts OR Accounting
4Accounting+Department
5Director+of+Accounting

</tbody>
Norfolk

Worksheet Formulas
CellFormula
C1=SUMPRODUCT(--ISNUMBER(FIND(" "&B1&" "," "&A1:A5&" ")))

</tbody>

<tbody>
</tbody>

#### Fluff

##### MrExcel MVP, Moderator
Glad we could help & thanks for the feedback

1,082,295
Messages
5,364,359
Members
400,792
Latest member
Dxmiian

### This Week's Hot Topics

• populate from drop list with multiple tables
Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
• Find list of words from sheet2 in sheet1 before a comma and extract text vba
Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
• Dynamic Formula entry - VBA code sought
Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...