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
149
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

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
65,596
Office Version
  1. 365
Platform
  1. Windows
How about
Excel Formula:
=SUBSTITUTE(TEXTJOIN(", ",,IF(ISNUMBER(SEARCH("^",A2)),"fruit",0),IF(ISNUMBER(SEARCH("^",B2)),"veg",0)),"0, 0","")
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
37,546
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
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,""))," ",", ")
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
65,596
Office Version
  1. 365
Platform
  1. Windows
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
 

Forum statistics

Threads
1,147,518
Messages
5,741,637
Members
423,675
Latest member
Dea21

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
Top