Searching for different strings of text

ellison

Active Member
Joined
Aug 1, 2012
Messages
356
Office Version
  1. 365
Platform
  1. Windows
Hi, we found a really helpful formula to search for multiple strings of text... but we are wondering if it could be tweaked to show what actual info was found:

Formula in C2:
VBA Code:
=IF(COUNT(SEARCH({"bulk","reel","tube"},B2)),"vocab-review","")

This will search B2 for any of the terms listed (bulk, reel or tube) and return "vocab-review" if it does.

Is there to actually change that into showing which of those terms was actually found?

(Also trying to make this not case dependent, and take into account that Col B often has blanks)

RowTo be reviewedHelpful Formula for: does it contain "Bulk, tube or reel"?What We'd Like!
2bulk packed 10Kvocab-reviewbulk
33rd party
4
5brown
6reels of 5Kvocab-reviewreel
7REELvocab-reviewreel
8
9tubesvocab-reviewtube
10


Thanks for any help you can suggest!
 

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.
What about something like this:

1694716637540.png



I've added the formatting purely to make it easier to read.

Steps from the inside out:
  1. SEARCH - returns a number, if it exists.
  2. ISNUMBER - returns true or false.
  3. IFS - Each condition specified with a catch all "---" at the end.

 
Upvote 0
Sorry but I'm getting an error message popping up about "You've entered too few arguments"

Here's what I entered into C2:

VBA Code:
=IFNA(IFS(ISNUMBER(SEARCH("bulk",$B2)),"bulk",ISNUMBER(SEARCH("reel",$B2)),"reel",ISNUMBER(SEARCH("tube",$B2)),"tube","---")

Have I left a typo in there?
 
Upvote 0
mini sheet attached....
I left the equals sign out of C2 so that the sheet would copy to the cliipboard

Book3
C
2IFNA(IFS(ISNUMBER(SEARCH("bulk",$B2)),"bulk",ISNUMBER(SEARCH("reel",$B2)),"reel",ISNUMBER(SEARCH("tube",$B2)),"tube","---")
Sheet1
 
Upvote 0
Just get rid of the IFNA as it's not needed & add a 1 to just before the "---"
Excel Formula:
=IFS(ISNUMBER(SEARCH("bulk",$B2)),"bulk",ISNUMBER(SEARCH("reel",$B2)),"reel",ISNUMBER(SEARCH("tube",$B2)),"tube",1,"---")
 
Upvote 0
Solution
I just pasted my formula and your formula next to each other, mine being above. It's always the brackets! If you look closely, you've left out the closing bracket for ISNUMBER tube. Other than that, it was perfect! ;)

IFNA(IFS(ISNUMBER(SEARCH("bulk",$B2)),"bulk",ISNUMBER(SEARCH("reel",$B2)),"reel",ISNUMBER(SEARCH("tube",$B2)),"tube"),"")
IFNA(IFS(ISNUMBER(SEARCH("bulk",$B2)),"bulk",ISNUMBER(SEARCH("reel",$B2)),"reel",ISNUMBER(SEARCH("tube",$B2)),"tube","")
 
Upvote 0
Absolutely brilliant, huge thanks to all who contributed


(And thanks for the tip on the mini sheet Fluff, that makes things a whole lot easier)
 
Upvote 0
@martinshort In future please post your formulae to the board, rather than just an image. It helps to avoid typos & the like.

@ellison Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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