Return valuse that contain a string or two strings

Damo71

Board Regular
Joined
Aug 17, 2010
Messages
88
Hi

I have a list of book titles in A1:100.

In cell C1 the user enters a string of one word (and, if possible, two words separated by a space*)

In cells D1 to D5 I need formulas to return the full book titles that contain the word or words the user has entered.

*e.g. if "Journey to the Center of the Earth" is in A1, and the user enters "Journey Earth" in C1, then D1 will return
"Journey to the Center of the Earth", the next matching entry will be in D2 and so on, up to 5 matches. If not possible with multiple words could you please help me with just a single string?

How can I do this please?

Many thanks
 
Last edited:

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
This is for only 1 match
In D1 =index(A:A,match("*" & c1 & "*", A:A,0))

This would be better accomplished with a VBA macro/routine
 
Upvote 0
Thanks that works well on the one word search.
VBA is not an option because the end user will often be using a tablet to enter his data.
 
Upvote 0
Bump

Can anyone help me with a formula (not vba) which will return cells that match TWO partial string matches?

For example, My lookup area contains book titles (in A1:100) One of which is "Journey to the Center of the Earth". Lets say I enter the two search words in C1 & C2 ("Journey" & "Earth"). How do I return the result "Journey to the Center of the Earth" in D1?

And is there a way to copy the formula down, say 5 rows so that it will display the first five matches?

Thanks
 
Last edited:
Upvote 0
This sort of thing is tricky, if not impossible, to get exactly right (especially without vba).

- You didn't say whether the 2 words (eg Journey Earth) in C1 need to be in the same order in the title as they are in C1. I have assumed they do (note that cell A18 is not returned by my formula)
- In post 1 you talked about finding words but in post 4 you also talked about string matches. They are different things. I have assumed words and that is why cell A19 is not returned in my results. That cell does contain the string "journey" and the string "earth", but not the word "earth".
- However, the previous point then makes anything with punctuation tricky. Note that cell A6 is also not returned as my formula uses the existence of spaces to determine where the boundary of the word is.

Anyway, see if this is some use. C2 formula is copied down as far as you want.

Excel Workbook
ABC
1WorkJourney Earth
2Absalom, Absalom!A Journey from Earth to Mars
3A che punto la notteJourney to the Center of the Earth
4The Children of Men
5All Passion Spent
6Journey's End: Earth
7Alone on a Wide, Wide Sea
8A Journey from Earth to Mars
9Antic Hay
10Beyond the Mexique Bay
11Journey to the Center of the Earth
12Blithe Spirit
13Butter In a Lordly Dish
14By Grand Central Station I Sat Down and Wept
15Carrion Comfort
16A Catskill Eagle
17The Children of Men
18My Earth Journey
19Journey Beyond The Fire Hearth
20Cabbages and Kings
Search
 
Last edited:
Upvote 0
Hi!

Maybe the Array Formula (use Ctrl+Shift+Enter to enter the formula) below can help you:

In D1 and copy down until D5 (top 5):

=IFERROR(INDEX($A$1:$A$100,
SMALL(IF(MMULT(--ISNUMBER(SEARCH(" "&TRIM(MID(SUBSTITUTE($C$1," ",REPT(" ",90)),{1,91,181},90))&" "," "&$A$1:$A$100&" ")),{1;1;1})>0,
ROW($A$1:$A$100)),ROWS(D$1:D1))),"")


ABCDE
1Word20 Word70 Word53Word10 Word70 Word65Word20 Word70 Word53
2Word20 Word71 Word10Word20 Word71 Word10
3Word42 Word84 Word20Word53 Word24 Word65
4Word53 Word24 Word65Word65 Word48 Word71
5Word53 Word24 Word66Word10 Word76 Word75
6Word98 Word71 Word46
7Word27 Word21 Word21
8Word52 Word68 Word67
9Word65 Word48 Word71
10Word10 Word76 Word75
*****************************************************************************

<tbody>
</tbody>


Ps: the formula above work with up to three words (with spaces between).

Markmzz
 
Upvote 0

It's probably down to my explanation, but I waslooking only for results that contained all strings, not any.
Thanks so much for your time though. Peter SS has almost nailed it (that "almost" is also down to my not explaining well enough)
 
Upvote 0
It's probably down to my explanation, but I waslooking only for results that contained all strings, not any.
Thanks so much for your time though. Peter SS has almost nailed it (that "almost" is also down to my not explaining well enough)

Try this small modification (Array Formula - use Ctrl+Shift+Enter to enter the formula):

=IFERROR(INDEX($A$1:$A$10,
SMALL(IF(MMULT(--ISNUMBER(SEARCH(" "&TRIM(MID(SUBSTITUTE($C$1," ",REPT(" ",90)),{1,91,181},90))&" "," "&$A$1:$A$10&" ")),{1;1;1})
=
(LEN($C$1)-LEN(SUBSTITUTE($C$1," ",""))+1)
,ROW($A$1:$A$10)),ROWS(D$1:D1))),"")

Markmzz
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,446
Members
449,083
Latest member
Ava19

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