is it possible to "nest" two or more searches with a "textjoin" into one macro or function so the result is text? Example attached...

sadams1

Board Regular
Joined
Aug 19, 2006
Messages
216
Book1.xlsx
ABCDEFGHIJ
1fruitvegsearch 1search 2textjoinmanually copy column F, paste values
2apple^broccoli^fruitvegfruit,vegfruit,veg
3applebroccoli  0,0
4orange^broccoli^fruitvegfruit,vegfruit,veg
5orangekale  0,0
6orange^tomato^fruitvegfruit,vegfruit,vegis it possible to "nest" these steps into one macro or function so the result is text? (column G)
7orangetomato^ veg0,veg0,veg
8orangebeets  0,0
9orange^beetsfruit fruit,0fruit,0
10
data
Cell Formulas
RangeFormula
D2:D9D2=IF(ISNUMBER(SEARCH("^",A2)),"fruit",0)
E2:E9E2=IF(ISNUMBER(SEARCH("^",B2)),"veg",0)
F2:F9F2=TEXTJOIN(",",TRUE,D2,E2)
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
How about
Excel Formula:
=SUBSTITUTE(TEXTJOIN(", ",,IF(ISNUMBER(SEARCH("^",A2)),"fruit",0),IF(ISNUMBER(SEARCH("^",B2)),"veg",0)),"0, 0","")
 
Upvote 0
Your "blank" cells apparently have 0's in them (at least that is what comes through when I copy your XL2BB file) so I guess you have your settings set to hide zero values in your cells. Given that, this formula should work...
Excel Formula:
=SUBSTITUTE(TRIM(SUBSTITUTE(TEXTJOIN(" ",TRUE,D2:E2),0,""))," ",", ")
 
Upvote 0
Glad we could help & thanks for the feedback.

Also you need to mark the post that helped you most as the solution. Not your post saying it works, especially as you haven't said which formula works. Thanks
 
Upvote 0

Forum statistics

Threads
1,213,487
Messages
6,113,938
Members
448,534
Latest member
benefuexx

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