• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

EXCEL FORMULAL- Searching for multiple sub-strings in a main string

Harry001

New Member
Hi,
I have test data as below. I want to search col.B sub_string in col.A String, if the substring is present in col.A then return the sub_string value. Can anyone suggest an excel formula/solution for this problem.
Test Data.jpg

Thanks,
Harry
 
Ok now, I have made the sample, and as to your sample data you can use the simple:
=MID(A2,SEARCH("Name?",A2),5)

But I am sure this is not you're looking for.
You can use this in C2 (if I am on right track) :

=IFERROR(MID(A2,IF(LEN(B2)>0,SEARCH(B2,A2),0),LEN(B2)),MID(A2,FIND(":",A2)+1,(FIND(";",A2)-FIND(":",A2))-1))


See the attached.

Regards,
 

Attachments

  • Search String - Harry001.xlsx
    9.1 KB · Views: 9
Hi Khalid,
Thanks for the formula. It works.
Can we extend this formula for the huge datasets. Let's say Col.A -1000 rows to search and Col.B 40 different sub_strings.
& Is there a way to use Combination of VLOOKUP, SEARCH and FIND.
Please let me know.

Thanks
Harsha.
 
@ Harry001
Based on the @Khalid NGO attachment.

=IF(COUNTIF($B$2:$B$5,MID(A2,FIND(":",A2)+1,(FIND(";",A2)-FIND(":",A2))-1)),MID(A2,FIND(":",A2)+1,(FIND(";",A2)-FIND(":",A2))-1),"")
 
A little sorter!

=IFERROR(INDEX($B$2:$B$6,MATCH(MID(A2,FIND(":",A2)+1,(FIND(";",A2)-FIND(":",A2))-1),$B$2:$B$6,0)),"")
 
Hi Khalid,
Thanks for the formula. It works.
Can we extend this formula for the huge datasets. Let's say Col.A -1000 rows to search and Col.B 40 different sub_strings.
& Is there a way to use Combination of VLOOKUP, SEARCH and FIND.
Please let me know.

Thanks
Harsha.

Hi Harsha,
Good day...

Not sure how your real data is looks like, I will again ask you to post the sample file, if there is sensitive data, replace it with fake; and mention your expected result manually.

Meanwhile check the various posted solution.

Regards,
 
Good formulas @Deepak

Here is one more that is generic.

Assuming your substrings are in E3:E6 and the cell to match is B3,


=INDEX($E$3:$E$6,SUM(COUNTIFS(B3,"*"&$E$3:$E$6&"*")*ROW($A$1:$A$4)))

Array formula, so press CTRL+Shift+Enter after typing.

Here is the sample workbook.

A while ago we had a homework problem exactly like this. See: http://chandoo.org/wp/2012/12/14/find-text-pattern/
 

Attachments

  • substring-search.xlsx
    9 KB · Views: 5
Back
Top