A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

how to count if cell "contains" a word



 
 
Thread Tools Display Modes
  #1  
Old July 11th, 2008, 11:20 PM posted to microsoft.public.excel.worksheet.functions
cjlatta
external usenet poster
 
Posts: 29
Default how to count if cell "contains" a word

(Using Excel2003/WinXP) I am trying to count the number of times 2 values
are in a cell. The string may contain the values ",abcd, abcf," or ",abcf,
abcd," The other part that's stumping me is the string could be ",abcd,
abcf, abcg," (or longer). I am wanting to know the number of times the cell
contains "abcd" and "abcf" no matter what order it's in. I will try to show
an example below:

Values
1,abcd,
2 ,abcd, abcf,
3 ,abcd, abcf, abcg,
4 ,abcd, abcg,
5 ,abcf, abcd,

I would want to include cell 2, cell 3, and cell 5 in my count, but not 1 or
4. Can I do this?
Any help greatly appreciated.

  #2  
Old July 12th, 2008, 12:02 AM posted to microsoft.public.excel.worksheet.functions
RagDyeR
external usenet poster
 
Posts: 3,482
Default how to count if cell "contains" a word

Does this work for you:

=SUM(COUNTIF(A1:A5,{"*abcd, abcf*","*abcf,abcd*"}))

Assuming there is *no* possibility of there being:

"abcd, abcg, abcf"

--
HTH,

RD

---------------------------------------------------------------------------
Please keep all correspondence within the NewsGroup, so all may benefit !
---------------------------------------------------------------------------
"cjlatta" wrote in message
...
(Using Excel2003/WinXP) I am trying to count the number of times 2 values
are in a cell. The string may contain the values ",abcd, abcf," or
",abcf,
abcd," The other part that's stumping me is the string could be ",abcd,
abcf, abcg," (or longer). I am wanting to know the number of times the
cell
contains "abcd" and "abcf" no matter what order it's in. I will try to
show
an example below:

Values
1,abcd,
2 ,abcd, abcf,
3 ,abcd, abcf, abcg,
4 ,abcd, abcg,
5 ,abcf, abcd,

I would want to include cell 2, cell 3, and cell 5 in my count, but not 1
or
4. Can I do this?
Any help greatly appreciated.



  #3  
Old July 12th, 2008, 12:08 AM posted to microsoft.public.excel.worksheet.functions
robzrob
external usenet poster
 
Posts: 114
Default how to count if cell "contains" a word

On Jul 11, 11:20*pm, cjlatta
wrote:
(Using Excel2003/WinXP) *I am trying to count the number of times 2 values
are in a cell. *The string may contain the values ",abcd, abcf," or ",abcf,
abcd," *The other part that's stumping me is the string could be ",abcd,
abcf, abcg," (or longer). *I am wanting to know the number of times the cell
contains "abcd" and "abcf" no matter what order it's in. *I will try to show
an example below:

* Values
1,abcd,
2 ,abcd, abcf,
3 ,abcd, abcf, abcg,
4 ,abcd, abcg,
5 ,abcf, abcd,

I would want to include cell 2, cell 3, and cell 5 in my count, but not 1 or
4. *Can I do this?
Any help greatly appreciated.


If you don't mind having another column and assuming the 'words' are
in B1, B2, etc, in C1 put =FIND("abcd",B1)*FIND("abcf",B1) and copy
down. Then at the bottom of column C, assuming 10 rows, put
=COUNTIF(C1:C10,"0").
  #4  
Old July 12th, 2008, 01:16 AM posted to microsoft.public.excel.worksheet.functions
Ron Rosenfeld
external usenet poster
 
Posts: 3,719
Default how to count if cell "contains" a word

On Fri, 11 Jul 2008 15:20:01 -0700, cjlatta
wrote:

(Using Excel2003/WinXP) I am trying to count the number of times 2 values
are in a cell. The string may contain the values ",abcd, abcf," or ",abcf,
abcd," The other part that's stumping me is the string could be ",abcd,
abcf, abcg," (or longer). I am wanting to know the number of times the cell
contains "abcd" and "abcf" no matter what order it's in. I will try to show
an example below:

Values
1,abcd,
2 ,abcd, abcf,
3 ,abcd, abcf, abcg,
4 ,abcd, abcg,
5 ,abcf, abcd,

I would want to include cell 2, cell 3, and cell 5 in my count, but not 1 or
4. Can I do this?
Any help greatly appreciated.


If all the values are four characters, and/or there is no chance the string
being searched for could be found within another string (e.g. if 3, tabcdx, yz,
abcf is not a possibility) then:

=SUMPRODUCT(--ISNUMBER(SEARCH({"*abcd*abcf","*abcf*abcd"},A1:A5) ))
--ron
  #5  
Old July 12th, 2008, 01:16 AM posted to microsoft.public.excel.worksheet.functions
Rick Rothstein \(MVP - VB\)[_887_]
external usenet poster
 
Posts: 1
Default how to count if cell "contains" a word

Why not this...

=SUM(COUNTIF(A1:A5,{"*abcd*abcf*","*abcf*abcd*"}))

and then it won't matter if "abcd, abcg, abcf" is in there?

Rick


"RagDyer" wrote in message
...
Does this work for you:

=SUM(COUNTIF(A1:A5,{"*abcd, abcf*","*abcf,abcd*"}))

Assuming there is *no* possibility of there being:

"abcd, abcg, abcf"

--
HTH,

RD

---------------------------------------------------------------------------
Please keep all correspondence within the NewsGroup, so all may benefit !
---------------------------------------------------------------------------
"cjlatta" wrote in message
...
(Using Excel2003/WinXP) I am trying to count the number of times 2
values
are in a cell. The string may contain the values ",abcd, abcf," or
",abcf,
abcd," The other part that's stumping me is the string could be ",abcd,
abcf, abcg," (or longer). I am wanting to know the number of times the
cell
contains "abcd" and "abcf" no matter what order it's in. I will try to
show
an example below:

Values
1,abcd,
2 ,abcd, abcf,
3 ,abcd, abcf, abcg,
4 ,abcd, abcg,
5 ,abcf, abcd,

I would want to include cell 2, cell 3, and cell 5 in my count, but not 1
or
4. Can I do this?
Any help greatly appreciated.




  #6  
Old July 12th, 2008, 01:17 AM posted to microsoft.public.excel.worksheet.functions
Ron Rosenfeld
external usenet poster
 
Posts: 3,719
Default how to count if cell "contains" a word

On Fri, 11 Jul 2008 16:02:19 -0700, "RagDyer" wrote:

Does this work for you:

=SUM(COUNTIF(A1:A5,{"*abcd, abcf*","*abcf,abcd*"}))

Assuming there is *no* possibility of there being:

"abcd, abcg, abcf"

--
HTH,

RD


Pasting in the OP's data, your formula returns a count of 2. The OP wanted a
count of 3.
--ron
  #7  
Old July 12th, 2008, 05:23 AM posted to microsoft.public.excel.worksheet.functions
RagDyeR
external usenet poster
 
Posts: 3,482
Default how to count if cell "contains" a word

Why not?
I'll tell you why not.
I didn't think about it!bg
--
Regards,

RD

---------------------------------------------------------------------------
Please keep all correspondence within the NewsGroup, so all may benefit !
---------------------------------------------------------------------------
"Rick Rothstein (MVP - VB)" wrote in
message ...
Why not this...

=SUM(COUNTIF(A1:A5,{"*abcd*abcf*","*abcf*abcd*"}))

and then it won't matter if "abcd, abcg, abcf" is in there?

Rick


"RagDyer" wrote in message
...
Does this work for you:

=SUM(COUNTIF(A1:A5,{"*abcd, abcf*","*abcf,abcd*"}))

Assuming there is *no* possibility of there being:

"abcd, abcg, abcf"

--
HTH,

RD


--------------------------------------------------------------------------

-
Please keep all correspondence within the NewsGroup, so all may benefit

!

--------------------------------------------------------------------------

-
"cjlatta" wrote in message
...
(Using Excel2003/WinXP) I am trying to count the number of times 2
values
are in a cell. The string may contain the values ",abcd, abcf," or
",abcf,
abcd," The other part that's stumping me is the string could be

",abcd,
abcf, abcg," (or longer). I am wanting to know the number of times the
cell
contains "abcd" and "abcf" no matter what order it's in. I will try to
show
an example below:

Values
1,abcd,
2 ,abcd, abcf,
3 ,abcd, abcf, abcg,
4 ,abcd, abcg,
5 ,abcf, abcd,

I would want to include cell 2, cell 3, and cell 5 in my count, but not

1
or
4. Can I do this?
Any help greatly appreciated.





  #8  
Old July 12th, 2008, 05:26 AM posted to microsoft.public.excel.worksheet.functions
RagDyeR
external usenet poster
 
Posts: 3,482
Default how to count if cell "contains" a word

Yeah!

I see my typo.

Left out a space between the 2 words in the 2nd half of the array constant.

Thanks.
--
Regards,

RD

---------------------------------------------------------------------------
Please keep all correspondence within the NewsGroup, so all may benefit !
---------------------------------------------------------------------------
"Ron Rosenfeld" wrote in message
...
On Fri, 11 Jul 2008 16:02:19 -0700, "RagDyer"

wrote:

Does this work for you:

=SUM(COUNTIF(A1:A5,{"*abcd, abcf*","*abcf,abcd*"}))

Assuming there is *no* possibility of there being:

"abcd, abcg, abcf"

--
HTH,

RD


Pasting in the OP's data, your formula returns a count of 2. The OP

wanted a
count of 3.
--ron


  #9  
Old July 14th, 2008, 03:15 PM posted to microsoft.public.excel.worksheet.functions
cjlatta
external usenet poster
 
Posts: 29
Default how to count if cell "contains" a word

Unfortunately, not all the values are four characters. Like the suggestion
though!
Thanks for the info.

"Ron Rosenfeld" wrote:

On Fri, 11 Jul 2008 15:20:01 -0700, cjlatta
wrote:

(Using Excel2003/WinXP) I am trying to count the number of times 2 values
are in a cell. The string may contain the values ",abcd, abcf," or ",abcf,
abcd," The other part that's stumping me is the string could be ",abcd,
abcf, abcg," (or longer). I am wanting to know the number of times the cell
contains "abcd" and "abcf" no matter what order it's in. I will try to show
an example below:

Values
1,abcd,
2 ,abcd, abcf,
3 ,abcd, abcf, abcg,
4 ,abcd, abcg,
5 ,abcf, abcd,

I would want to include cell 2, cell 3, and cell 5 in my count, but not 1 or
4. Can I do this?
Any help greatly appreciated.


If all the values are four characters, and/or there is no chance the string
being searched for could be found within another string (e.g. if 3, tabcdx, yz,
abcf is not a possibility) then:

=SUMPRODUCT(--ISNUMBER(SEARCH({"*abcd*abcf","*abcf*abcd"},A1:A5) ))
--ron

  #10  
Old July 14th, 2008, 03:16 PM posted to microsoft.public.excel.worksheet.functions
cjlatta
external usenet poster
 
Posts: 29
Default how to count if cell "contains" a word

Thank you! This will do it for me, especially since the values can be in any
part of the sequence!


"Rick Rothstein (MVP - VB)" wrote:

Why not this...

=SUM(COUNTIF(A1:A5,{"*abcd*abcf*","*abcf*abcd*"}))

and then it won't matter if "abcd, abcg, abcf" is in there?

Rick


"RagDyer" wrote in message
...
Does this work for you:

=SUM(COUNTIF(A1:A5,{"*abcd, abcf*","*abcf,abcd*"}))

Assuming there is *no* possibility of there being:

"abcd, abcg, abcf"

--
HTH,

RD

---------------------------------------------------------------------------
Please keep all correspondence within the NewsGroup, so all may benefit !
---------------------------------------------------------------------------
"cjlatta" wrote in message
...
(Using Excel2003/WinXP) I am trying to count the number of times 2
values
are in a cell. The string may contain the values ",abcd, abcf," or
",abcf,
abcd," The other part that's stumping me is the string could be ",abcd,
abcf, abcg," (or longer). I am wanting to know the number of times the
cell
contains "abcd" and "abcf" no matter what order it's in. I will try to
show
an example below:

Values
1,abcd,
2 ,abcd, abcf,
3 ,abcd, abcf, abcg,
4 ,abcd, abcg,
5 ,abcf, abcd,

I would want to include cell 2, cell 3, and cell 5 in my count, but not 1
or
4. Can I do this?
Any help greatly appreciated.





 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:48 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.