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 20th, 2002, 02:31 PM   #1
voryzover
New Member
 
Join Date: May 2002
Posts: 8
Default

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
voryzover is offline   Reply With Quote
Old May 20th, 2002, 02:47 PM   #2
Yogi Anand
MrExcel MVP
 
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
Default

Have you tried using

=SEARCH("*rang*",A1,1) .... if your array is in cell A1

Regards!
__________________
Regards!

Yogi Anand, D.Eng, P.E.
Energy Efficient Building Network LLC
www.energyefficientbuild.com
Yogi Anand is offline   Reply With Quote
Old May 20th, 2002, 02:51 PM   #3
Asala42
Board Regular
 
Join Date: Feb 2002
Location: Southfield,MI USA
Posts: 1,030
Default

Hey,

This would give you a yes or no on whether or not "rang" appears anywhere in your text:

Assuming range A1:A3 (containing "apple","orange", and "lemon" respectively).

=IF(COUNTIF(A1:A3,"*rang*")>0,"yes","no")

Adam
Asala42 is offline   Reply With Quote
Old May 20th, 2002, 02:53 PM   #4
Asala42
Board Regular
 
Join Date: Feb 2002
Location: Southfield,MI USA
Posts: 1,030
Default

Heh, you were faster on the draw Yogi

Adam
Asala42 is offline   Reply With Quote
Old May 20th, 2002, 02:55 PM   #5
voryzover
New Member
 
Join Date: May 2002
Posts: 8
Default

Yogi,
Thanks for your reply.
No. The array is huge and is located at a range of cells (rather than a single cell).
voryzover is offline   Reply With Quote
Old May 20th, 2002, 03:01 PM   #6
voryzover
New Member
 
Join Date: May 2002
Posts: 8
Default

Asala,
Yours worked out perfectly, I knew this was easy. Thanks a lot guys.
voryzover is offline   Reply With Quote
Old Apr 14th, 2008, 01:23 PM   #7
ralegg
New Member
 
Join Date: Apr 2008
Posts: 3
Question Re: Search for a "substring" within an Array of Strings

How would you go about having it return the value you were checking for in the cell instead of the CHECKIF statement's true/false. Preferably not with VBA macros, I know it's easier but you can't undo it as easily if you mess up.
ralegg is offline   Reply With Quote
Old Apr 14th, 2008, 02:16 PM   #8
Domenic
MrExcel MVP
 
Join Date: Mar 2004
Location: Canada
Posts: 12,423
Default Re: Search for a "substring" within an Array of Strings

Quote:
Originally Posted by ralegg View Post
How would you go about having it return the value you were checking for in the cell instead of the CHECKIF statement's true/false. Preferably not with VBA macros, I know it's easier but you can't undo it as easily if you mess up.
Assuming that A2:A10 contains the array of strings, and C2 contains the substring of interest, try...

=IF(ISNUMBER(MATCH("*"&C2&"*",$A$2:$A$10,0)),C2,"")

Hope this helps!
Domenic is offline   Reply With Quote
Old Apr 14th, 2008, 03:20 PM   #9
ralegg
New Member
 
Join Date: Apr 2008
Posts: 3
Default Re: Search for a "substring" within an Array of Strings

How about if I am looking for a range of numbers in that array.
For example:

Array1: 10, 40, 63, 78, 112, 560

and I want the number that is between 75 and 100. How would I do this? Also, how does it react if there was an extra 90 in the array and there were potentially 2 numbers within the range?

Thanks!
ralegg is offline   Reply With Quote
Old Apr 14th, 2008, 03:56 PM   #10
ralegg
New Member
 
Join Date: Apr 2008
Posts: 3
Smile Re: Search for a "substring" within an Array of Strings

Actually, I figured it out using a HLookup formula, thank you though Domenic because it took looking at your formula for me to figure out how to come up with the one that I needed!

BV206=HLOOKUP(150,AK206:BT206,1,TRUE)

BW206=HLOOKUP(420,AK206:BT206,1,TRUE)

BX206=IF(AND(BV206<=150,BV206>=61,BW206<=420,BW206>=300),"Viable","Non-Viable")

(Cell Number=Formula)
ralegg 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 04:29 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