Multi Line Cell - Find Text String

CF64

Board Regular
Joined
Feb 17, 2021
Messages
50
Office Version
  1. 365
Platform
  1. Windows
Hello,

Would there be a way to look into an adjacent cell to determine which line to look on to return the desired text string?

In your formula above you have "//m[3]" with 3 being the line to look at to return the text string on line 3.

I have a table with 4 columns
Column A, Row 2 - a list of text separated with line breaks
Column B, Row 2 - a list of text separated with line breaks
Column C, Row 2 - is this formula which tells me which line in A2, the specific text string listed in C1, appears - =IFERROR(1+LEN(LEFT(a2,SEARCH(c1,a2)-1))-LEN(SUBSTITUTE(LEFT(a2,SEARCH(c1,a2)-1),CHAR(10),"")),0)
Column D, Row 2 - would be a formula to tell me the string of text in B2 corresponding to the line identified in C2 - Could I modify this formula to achieve that?
=FILTERXML("<k><m>"&SUBSTITUTE(A2,CHAR(10),"</m><m>")&"</m></k>","//m[3]")[/CODE]

I tried to insert C2 into "//m[c2]" but received a #VALUE error.

Thank you

ABCD
1QuestionsAnswersMy favorite carAnswer of Interest
2My favorite snack
My favorite animal
My favorite car
My favorite color
Doritos
Dog
Corvette
Blue
3Corvette
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
As there are newer functions in xl, you can do that with using C2 like
Fluff.xlsm
ABCD
1QuestionsAnswersMy favorite carAnswer of Interest
2My favorite snack My favorite animal My favorite car My favorite colorDoritos Dog Corvette BlueCorvette
Sheet5
Cell Formulas
RangeFormula
D2D2=XLOOKUP(C1,TEXTSPLIT(A2,CHAR(10)),TEXTSPLIT(B2,CHAR(10)))
 
Upvote 0
Solution
As there are newer functions in xl, you can do that with using C2 like
Fluff.xlsm
ABCD
1QuestionsAnswersMy favorite carAnswer of Interest
2My favorite snack My favorite animal My favorite car My favorite colorDoritos Dog Corvette BlueCorvette
Sheet5
Cell Formulas
RangeFormula
D2D2=XLOOKUP(C1,TEXTSPLIT(A2,CHAR(10)),TEXTSPLIT(B2,CHAR(10)))
Awesome! Thank you!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,265
Members
452,627
Latest member
KitkatToby

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