Find which of multiple Unique Text Strings are present within a Longer Text String

britz

New Member
Joined
Apr 7, 2013
Messages
5
Im using Excel 2007 & Windows 7. I do not have any programing or VBA experience.

I have managed to be able to find when the "Unique Text String" is present in a "Longer Text String" by using the function =SEARCH(TRIM(D3),TRIM(A3)).
The "Longer Text String" varies in length & sometimes contains extra spaces, hence the need for the Trim operation.

The issue I have, is that I now want to be able to search each "Longer Text String" & identify which of the "Unique Text Strings" is present, then tell me the corresponding related No.
If it were only 5 "Unique Text Strings", then it would be easy to create 5 columns, one for each of the "Unique Text Strings" to the right & customise the formula for each "Unique Test String" in each column.

The tricky bit is there are over 60 "Unique Text Strings" & thousands of "Longer Text Strings". So I would like to do this in a lot less than 60 separate functions.
I hope you can give me some ideas?


[TABLE="width: 500"]
<tbody>[TR]
[TD]Longer Text Strings
[/TD]
[TD][/TD]
[TD]No.
[/TD]
[TD]Unique Test String
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]The Brown Fox in the box 1
[/TD]
[TD][/TD]
[TD]1
[/TD]
[TD]Brown Fox
[/TD]
[/TR]
[TR]
[TD]The Black Cat on the mat
[/TD]
[TD][/TD]
[TD]2
[/TD]
[TD]Black Cat
[/TD]
[/TR]
[TR]
[TD]The Bird in the Tree
[/TD]
[TD][/TD]
[TD]3
[/TD]
[TD]Tree
[/TD]
[/TR]
[TR]
[TD]The Snake on the Grass
[/TD]
[TD][/TD]
[TD]4
[/TD]
[TD]Snake
[/TD]
[/TR]
[TR]
[TD]The man on the moon
[/TD]
[TD][/TD]
[TD]5
[/TD]
[TD]Moon
[/TD]
[/TR]
[TR]
[TD]The Brown Owl on the Barn
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]The Dog fighting the Cat
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]The Small Tree in the Garden
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]The Brown Fox in the box 2
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Hi Hiker95,

Thanks again for your time & your clear instructions.
Ive not previously run macro code other than the basic record function.
I followed your instructions to a tee & to my surprise, this code worked like a charm. Really cool how multiple results appear int he one cell where applicable.

Thanks again for your time & Interest.

Regards,

Britz
 
Upvote 0

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
britz,

Thanks for the feedback.

You are very welcome. Glad I could help.

And, come back anytime.
 
Upvote 0
Hi Britz,

I misunderstood your requirement, I assumed you wanted a count of all the Unique Strings within the longer string!

You have been provided with an excellent solution by Hiker95, but thanks for the feedback. :biggrin:

Excel Workbook
ABCDEFGH
1Longer Text StringsSingle String ResultNo.Unique Test String# Uniq Strings
2The Brown Fox in the box 111Brown Fox1
3The Black Cat on the mat72Black Cat3
4The Bird in the Tree33Tree1
5The Snake on the Grass74Snake2
6The man on the moon75Moon2
7The Brown Owl on the Barn76Cat1
8The Dog fighting the Cat67On1
9The Small Tree in the Garden31
10The Brown Fox in the box 211
11
Sheet2


Ak
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top