Formula to Find a String of Text and Return a Specific Value

hkydad

Board Regular
Joined
May 16, 2013
Messages
68
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am trying to write an excel formula that reads through the Doc Code column "-sann", then I want it to return "A-BCD" or if it finds "-ann" then I want it to return "M-NOPQ". A small sample is below.


REX-SANNA-BDE
TRE-ANNM-NOPQ
JONNY-ANNM-NOPQ

Thank you in advance for any assistance.
 
Hi,

I am trying to write an excel formula that reads through the Doc Code column "-sann", then I want it to return "A-BCD" or if it finds "-ann" then I want it to return "M-NOPQ". A small sample is below.


REX-SANNA-BDE
TRE-ANNM-NOPQ
JONNY-ANNM-NOPQ

Thank you in advance for any assistance.
A small sample but does this work for you?

Book2.xlsx
BCDEFG
2
3REX-SANNA-BDEA-BDE
4TRE-ANNM-NOPQ
5JONNY-ANNM-NOPQ
6
Sheet1
Cell Formulas
RangeFormula
F3F3=XLOOKUP("*ann*",C3:C5,D3:D5,"",2)
 
Upvote 0
Try

Book2
ABC
1REX-SANNA-BCDE
2TRE-ANNM-NOPQ
3JONNY-ANNM-NOPQ
4
5
6
Sheet1
Cell Formulas
RangeFormula
B1:B3B1=IF(ISNUMBER(SEARCH("-Sann",A1)),"A-BCDE",IF(ISNUMBER(SEARCH("-ANN",A1)),"M-NOPQ",""))
 
Upvote 0
Solution
Thank you @ Sufuyan97. This is exactly what I was looking for to solve this problem. This solution will eliminate the need for typeing the codes in 1 by 1, espcially when there will be 300+ rows of data.

 
Upvote 0
Without the nested IFs:
=XLOOKUP(TEXTAFTER(A1,"-",,,,""),{"SANN","ANN"},{"A-BCD","M-NOPQ"},"",0)
 
Upvote 0

Forum statistics

Threads
1,226,841
Messages
6,193,291
Members
453,788
Latest member
drcharle

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