How to "match" or "search" multiple/partial text values out of sequential order and still work

wbstadeli

Board Regular
Joined
Mar 11, 2016
Messages
153
Office Version
  1. 365
Platform
  1. Windows
Hi guys,

Is there any way to search a cell for text words that the words do not have to be in order? I can get this formula to work using if everything i type is in the exact order, but not if i try to switch some words around.

Formula using search: =isnumber(search(trim(C1),A1))

See example:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]the dog runs fast[/TD]
[TD][/TD]
[TD]dog runs[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

This returns a "True", however see next example:


[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]the dog runs fast[/TD]
[TD][/TD]
[TD]runs dog[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


This returns "False".

Anyway to get this to be true? Im open to helper columns if needed as well. Thanks for looking!
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
How many words would be in C? If more than two, you may want to try VBA.

You can use the following two string functions to get "runs" and "dog".

=LEFT(C1,FIND(" ",C1)) <- for "runs"
=RIGHT(C1,LEN(C1)-FIND("dog",C1)+1) <- for "dog"

=IF(AND(ISNUMBER(SEARCH(LEFT(C1,FIND(" ",C1)),A1)),ISNUMBER(SEARCH(RIGHT(C1,LEN(C1)-FIND("dog",C1)+1),A1))),"TRUE","FALSE")
 
Upvote 0
How many words would be in C? If more than two, you may want to try VBA.

You can use the following two string functions to get "runs" and "dog".

=LEFT(C1,FIND(" ",C1)) <- for "runs"
=RIGHT(C1,LEN(C1)-FIND("dog",C1)+1) <- for "dog"

=IF(AND(ISNUMBER(SEARCH(LEFT(C1,FIND(" ",C1)),A1)),ISNUMBER(SEARCH(RIGHT(C1,LEN(C1)-FIND("dog",C1)+1),A1))),"TRUE","FALSE")

Thanks yky, i apologize i wasn't very clear with my post. The words/ numbers would be variable, so i cant have anything the finds the actual word (example; "dog" or "runs", rather "anyword" or "anynumber"), if that makes sense. Thanks for your reply though!
 
Upvote 0
You can substitute "dog" with the first formula to get the following:

=IF(AND(ISNUMBER(SEARCH(LEFT(C1,FIND(" ",C1)),A1)),ISNUMBER(SEARCH(RIGHT(C1,LEN(C1)-FIND(LEFT(C1,FIND(" ",C1)),C1)+1),A1))),"TRUE","FALSE")

As you can see, with only two words, the formula is already so long. With more than two words, you need to find other solutions such as VBA.
 
Upvote 0

Forum statistics

Threads
1,223,577
Messages
6,173,163
Members
452,503
Latest member
AM74

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