Forum Discussion
ngabrielyan
Aug 20, 2024Copper Contributor
How to find piece of specific text and return specific text.
Hello everyone, I am working on project and having hard time to find piece of text and return specific text. My formula works only with two variable, and I need to add one more. If column A contains piece of text "*MLTC*" return "MLTC", if contains "*NYIAP*"
=IFERROR(IF(SEARCH("*MLTC*",A2,1),"MLTC"),IF(SEARCH("*NYIAP MMC*",A2,1),"NYIAP"))
How should I add if cell does not contain NYIAP and MLTC return MMC. Thank you
A | B |
NYIAP MMC Initial | NYIAP |
MMC Initial NYIAP | NYIAP |
MMC Initial | MMC |
MLTC Initial | MLTC |
Peds Initial | MMC |
- Harun24HRBronze Contributor
ngabrielyan You may use IFS() function.
=IFERROR(IFS(ISNUMBER(SEARCH("MLTC",A2)),"MLTC",ISNUMBER(SEARCH("NYIAP",A2)),"NYIAP",ISNUMBER(SEARCH("MMC",A2)),"MMC"),"Not found")
- ngabrielyanCopper Contributor
Thank you so much Harun24HR!!!! Thank you for your help! 🙂
- SnowMan55Bronze Contributor
Does this do what you intend?
=IF( IFERROR(SEARCH("*NYIAP*",A2,1),FALSE),"NYIAP", IF( IFERROR(SEARCH("*MLTC*",A2,1),FALSE),"MLTC", "MMC" ) )
(Of course, you do not have to split that across multiple lines, as done here.)
- ngabrielyanCopper ContributorThank you so much @Snow Man55. !!!!!! thanks for the quick response !!!!!!
As variant
=IF( COUNTIF(A2, "*NYIAP*"), "NYIAP", IF( COUNTIF(A2, "*MLTC*"), "MLTC", "MMC") )
- ngabrielyanCopper ContributorThank you Sergei, I like your formula, it is short and simple. Thanks for your help!
ngabrielyan , you are welcome