Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default search within a range of cells?

I'm looking for an existing excel function or UDF that will search for
a text string within a range of cells. For example, if the string in
cell A1 is "my string" I would like to know if this string exists
within a range of cells (B1:B4), and if so how many times. It's
similar to countif, but the string that will be searched is in a
different cell (A1).

A1="my string"

B1="this is my string"
B2="this is not my string"
B3="this string is not it"
B4="string, strings, 123"

I would like a function to tell me how many times "my string" shows up
in the range B1:B4. (2 times)

I'm basically looking for a UDF equiviliant to the "find and replace"
feature in excel.

I've tried using COUNTIF, DCOUNT, SEARCH, and the FIND function
without any luck.

Please help! Thanks!!

Jason

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 857
Default search within a range of cells?

Jason,

You can use COUNTIF.. try:

=COUNTIF(B1:B4, "*" & A1 & "*")


--
Hope that helps.

Vergel Adriano


" wrote:

I'm looking for an existing excel function or UDF that will search for
a text string within a range of cells. For example, if the string in
cell A1 is "my string" I would like to know if this string exists
within a range of cells (B1:B4), and if so how many times. It's
similar to countif, but the string that will be searched is in a
different cell (A1).

A1="my string"

B1="this is my string"
B2="this is not my string"
B3="this string is not it"
B4="string, strings, 123"

I would like a function to tell me how many times "my string" shows up
in the range B1:B4. (2 times)

I'm basically looking for a UDF equiviliant to the "find and replace"
feature in excel.

I've tried using COUNTIF, DCOUNT, SEARCH, and the FIND function
without any luck.

Please help! Thanks!!

Jason


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15,768
Default search within a range of cells?

COUNTIF might be adequate in this case but this is a little more robust:

=SUMPRODUCT(--(ISNUMBER(SEARCH(" "&A1&" "," "&B1:B4&" "))))

Less of a chance for "false positives" but still not "bulletproof".

COUNTIF will count:

my strings
my stringer

SUMPRODUCT *won't* count:

my string, strings, 123

But COUNTIF will

Also, does the OP want to count multiple instances in a cell:

my string is my string

Biff

"Vergel Adriano" wrote in message
...
Jason,

You can use COUNTIF.. try:

=COUNTIF(B1:B4, "*" & A1 & "*")


--
Hope that helps.

Vergel Adriano


" wrote:

I'm looking for an existing excel function or UDF that will search for
a text string within a range of cells. For example, if the string in
cell A1 is "my string" I would like to know if this string exists
within a range of cells (B1:B4), and if so how many times. It's
similar to countif, but the string that will be searched is in a
different cell (A1).

A1="my string"

B1="this is my string"
B2="this is not my string"
B3="this string is not it"
B4="string, strings, 123"

I would like a function to tell me how many times "my string" shows up
in the range B1:B4. (2 times)

I'm basically looking for a UDF equiviliant to the "find and replace"
feature in excel.

I've tried using COUNTIF, DCOUNT, SEARCH, and the FIND function
without any luck.

Please help! Thanks!!

Jason




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CAN VLOOKUP SEARCH AN ENTIRE WORKSHEET INSTEAD OF RANGE OF CELLS BROCK8292 Excel Worksheet Functions 4 April 3rd 23 07:42 PM
Search range for text not in another range simon howard Excel Discussion (Misc queries) 3 March 28th 07 08:44 PM
Sumproduct (Range unknown, needs Search) ExcelQuestion Excel Worksheet Functions 8 May 3rd 06 07:24 AM
Search range of cells, find a value, output adjoining cell. How? nyys Excel Worksheet Functions 3 January 5th 06 01:48 PM
how do you search a range of cells... Xanadude Excel Discussion (Misc queries) 2 June 6th 05 05:30 AM


All times are GMT +1. The time now is 01:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"