Excel - counting cells containing a text string

P

Pegasus Host

I'm using excel 2002, and I want to count the number of cells in each row of
a database that contain a particular text string. Can anyone tell me how to
achieve this?
 
A

Aladin Akyurek

Whole string match:

=COUNTIF(Range,X2)

where X2 houses a criterion string.

Partial string match:

=COUNTIF(Range,X2&"*")

=COUNTIF(Range,"*"&X2)

=COUNTIF(Range,"*"&X2&"*")
 
P

Pegasus Host

That's worked thanks, but now I have a follow up question. In front of each
text string that's been found, there is a number which I need to total up.
As an example, the cells contain entries like
9@2 or 21.5 @2 or [email protected]
I'm able to total the number of cells that contain the text string @2
but how do I total all the digits in front of the @2
 
A

Aladin Akyurek

=SUM(IF(ISNUMBER(SEARCH("@",Range)),--LEFT(Range,SEARCH("@",Range)-1),0))

which you need to confirm with control+shift+enter instead of the usual
enter.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top