Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Finding strings within strings

Hello everyone!

Can anyone help me to determine how to do this: I need to
write a macro that will search certain cell to find
specific strings that cell *may* contain. For example,
say I would like to know exacly what fruits from the group
{"apples," "bananas," and "pears"} are listed in each
cell. Then, if a cell contains the text "Today I had
apples for lunch," or "Yesterday I had pears for lunch,"
the macro would return "apples" or "pears," respectively.

Any clue? Thank you very much in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Finding strings within strings

Rod,

You can use the InStr function to search for a string within a
string. For example,

If InStr(1, ActiveCell.Text, "apples") 0 Then
' string contains apples
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Rod" wrote in message
...
Hello everyone!

Can anyone help me to determine how to do this: I need to
write a macro that will search certain cell to find
specific strings that cell *may* contain. For example,
say I would like to know exacly what fruits from the group
{"apples," "bananas," and "pears"} are listed in each
cell. Then, if a cell contains the text "Today I had
apples for lunch," or "Yesterday I had pears for lunch,"
the macro would return "apples" or "pears," respectively.

Any clue? Thank you very much in advance.



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
find and replace numeric strings in larger text strings Mr Molio Excel Worksheet Functions 8 November 9th 11 05:17 PM
Finding 1 of 3 different strings in a string MarkMcG Excel Worksheet Functions 3 June 10th 08 05:55 PM
Finding test strings in a row which are missing from a column TonyStarr at cox dot net Excel Worksheet Functions 0 August 20th 06 10:05 PM
Finding text strings in complex situations Hardel Excel Discussion (Misc queries) 6 July 25th 06 01:55 PM
How to find number of pairs of strings from list of strings? greg_overholt Excel Worksheet Functions 5 January 27th 06 10:42 PM


All times are GMT +1. The time now is 10:39 PM.

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

About Us

"It's about Microsoft Excel"