MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old May 21st, 2002, 07:26 AM   #1
voryzover
New Member
 
Join Date: May 2002
Posts: 8
Default

Everyone, I posted the following below yesterday and got help from Yogi and Asala42.
When I posted this, it didn't occur to me that I would want to locate the main string in which the substring is found.

So to summarize: Search for a string (say rang) inside an array of strings placed over a range (say {"apple","orange","lemon"} placed at A1:A3). The command should return the 1st string that it finds a match (in that case this would be "orange")

My yesterday's entry is right below and I also pasted the link to the related discussion.

And as always, thanks a lot.

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

Hi everyone

First let me express my grattitude for everyone taking their time to answer questions on
this board. At least personnally speakig, this board is extremely valuable.

On to question: I know this must be a piece of cake for the experts.

I wish to search for a substring within an array of strings and just return back an indication
that the substring exists withing that array.

so for instance let the substring be "rang"
and let the array be
{"apple","orange","lemon"}.
I wish to put a single command line next to my substring and wish to search through that
range and return a key code if it exists. And then I will repeat the same search for other
substrings. For the moment being, I don't care too much about the number of occurences
or the exact cell address where they occur. All I wish to know is whether they exist in that
list or not.

So it looks to me it is like a SEARCH command but except on a range of text (Rather than
a single text) with an array formula. I have tried MATCH but my case is not an exact match
either.

Any help will be greatly appreciated.

Thanks

http://www.mrexcel.com/board/viewtop...c=8889&forum=2
voryzover is offline   Reply With Quote
Old May 21st, 2002, 07:42 AM   #2
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,319
Default


=INDEX(A1:A3,MATCH("*"&E1&"*",A1:A3,0))

Aladin Akyurek is offline   Reply With Quote
Old May 21st, 2002, 10:25 AM   #3
voryzover
New Member
 
Join Date: May 2002
Posts: 8
Default

Thanks Aladin, this worked out.
voryzover is offline   Reply With Quote
Old Oct 26th, 2011, 05:17 PM   #4
Simply
New Member
 
Join Date: Oct 2011
Posts: 6
Default Re: Substring Search within an Array of Strings (PART 2)

I have an array with PARTS across the column headings and PRODUCTS down the first column. I have 100 potential parts, which can be "grouped" into categories like color. For example, "red door", "red wheel", "red window", etc. can be collectively found under "red...".
Under each column is the number of the parts needed to produce each corresponding product, and the parts can be used on more than one product.


Here's an example of what I'm trying to achieve. I'd like a formula in cell A1 of Sheet2, which would search the top row of Sheet1 for any parts that have "red" in them, and then search column A in Sheet1 for any products that have "car" in them, and sum the total count needed to produce one of each of these.

http://http://pictureexample.blogspot.com/

The results should be:
columns B, F, J, N are included.
rows 2, 3, 8 are included.

so... cells B2, B3, B8, F2, F3, F8, J2, J3, J8, N2, N3, N8 would be summed.

How can I write a one-cell formula which will sum a count of all of the parts needed to produce one of each of the "red" products?
Simply is offline   Reply With Quote
Old Oct 27th, 2011, 05:13 AM   #5
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,319
Default Re: Substring Search within an Array of Strings (PART 2)

Quote:
Originally Posted by Simply View Post
I have an array with PARTS across the column headings and PRODUCTS down the first column. I have 100 potential parts, which can be "grouped" into categories like color. For example, "red door", "red wheel", "red window", etc. can be collectively found under "red...".
Under each column is the number of the parts needed to produce each corresponding product, and the parts can be used on more than one product.


Here's an example of what I'm trying to achieve. I'd like a formula in cell A1 of Sheet2, which would search the top row of Sheet1 for any parts that have "red" in them, and then search column A in Sheet1 for any products that have "car" in them, and sum the total count needed to produce one of each of these.

http://http://pictureexample.blogspot.com/

The results should be:
columns B, F, J, N are included.
rows 2, 3, 8 are included.

so... cells B2, B3, B8, F2, F3, F8, J2, J3, J8, N2, N3, N8 would be summed.
How can I write a one-cell formula which will sum a count of all of the parts needed to produce one of each of the "red" products?
Control+shift+enter, not just enter:

=SUM(IF(ISNUMBER(SEARCH("car",$A$2:$A$8)),IF(ISNUMBER(SEARCH("red",$B$1:$N$1)),$B$2:$N$8)))
__________________
Microsoft MVP - Excel
Aladin Akyurek is offline   Reply With Quote
Old Oct 27th, 2011, 09:40 AM   #6
Simply
New Member
 
Join Date: Oct 2011
Posts: 6
Default Re: Substring Search within an Array of Strings (PART 2)

Thank you Aladin!!

I never knew about these "secret" class of formulas!
Simply is offline   Reply With Quote
Old Oct 27th, 2011, 09:50 AM   #7
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,319
Default Re: Substring Search within an Array of Strings (PART 2)

Quote:
Originally Posted by Simply View Post
Thank you Aladin!!

I never knew about these "secret" class of formulas!
You are welcome. Thanks for providing feedback.
__________________
Microsoft MVP - Excel
Aladin Akyurek is offline   Reply With Quote
Old Oct 31st, 2011, 03:09 PM   #8
Simply
New Member
 
Join Date: Oct 2011
Posts: 6
Default Re: Substring Search within an Array of Strings (PART 2)

Aladin,

How would the formula need to be adjusted if I need to search for more than one string of characters in each cell? For example, if I needed to find the "red" AND "blue" parts for both the "trucks" AND "cars"?

Can the same formula be used?
Simply is offline   Reply With Quote
Old Nov 8th, 2011, 05:47 PM   #9
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,319
Default Re: Substring Search within an Array of Strings (PART 2)

Quote:
Originally Posted by Simply View Post
Aladin,

How would the formula need to be adjusted if I need to search for more than one string of characters in each cell? For example, if I needed to find the "red" AND "blue" parts for both the "trucks" AND "cars"?

Can the same formula be used?
Control+shift+enter, not just enter:
Code:
=SUM(IF(ISNUMBER(SEARCH("red",$B$1:$N$1))+
       ISNUMBER(SEARCH("blue",$B$1:$N$1)),
     IF(ISNUMBER(SEARCH("car",$A$2:$A$8))+
       ISNUMBER(SEARCH("truck",$A$2:$A$8)),$B$2:$N$8)))
__________________
Microsoft MVP - Excel
Aladin Akyurek is offline   Reply With Quote
Old Nov 9th, 2011, 08:54 AM   #10
Simply
New Member
 
Join Date: Oct 2011
Posts: 6
Default Re: Substring Search within an Array of Strings (PART 2)

Thank you again Aladin!

You have been most helpful to my project. I really appreciate it.
Simply is offline   Reply With Quote
Reply

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 06:49 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes