![]() |
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. |
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. |
All times are GMT +1. The time now is 04:37 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com