Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Counting String Matches in a Range

Currently I'm using this formula to count the number of string matches in a range:

=COUNTA(FILTER(D3:D723,FIND(A1, D3:D723)))

If A1="am" and range has "ham", "scammy", "pan"; then the cell will display 2.

It appears to work correctly, except for one thing- it displays a match of 1 if there are no matches. How can I fix this?

like image 660
HelpyHelperton Avatar asked Apr 03 '13 11:04

HelpyHelperton


People also ask

How do you count occurrences in a range?

You can use the =UNIQUE() and =COUNTIF() functions to count the number of occurrences of different values in a column in Excel.

How do you count the occurrences of a number or text in a range?

In Excel, I can tell you some simple formulas to quickly count the occurrences of a word in a column. Select a cell next to the list you want to count the occurrence of a word, and then type this formula =COUNTIF(A2:A12,"Judy") into it, then press Enter, and you can get the number of appearances of this word. Note: 1.


1 Answers

You can use:

=COUNTIF(D3:D723,"*"&A1&"*")

It counts the amount of cells in D3:D7243 that have the substring in Cell A1. The * are there as a wildcard in front and behind the substring.

I made a working example for you as well to look at.

UPDATE: fixed statement

like image 73
Javaaaa Avatar answered Sep 22 '22 06:09

Javaaaa