Search string and return multiple values

ljphil78

New Member
Joined
Feb 28, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi everyone, my excel formula knowledge is pretty limited so was after a little help
I have a column where i want to check if the cell contains a certain letter and if it does it returns a value, if it contains another letter it will return a different value

for example

OP001
OP002
OP003
OB001
OB002
OG001
OG002
OG003

if the string contains "P" return "Purple"
if the string contains "B" return "Blue"
if the string contains "G" return "Green"

I tried using OR and IF but got very confused lol
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
how about
=IF(ISNUMBER(SEARCH("P",A2,1)),"Purple", IF(ISNUMBER(SEARCH("B",A2,1)),"Blue", IF(ISNUMBER(SEARCH("G",A2,1)),"Green", "")))

Book2
AB
1
2OP001Purple
3OP002Purple
4OP003Purple
5OB001Blue
6OB002Blue
7OG001Green
8OG002Green
9OG003Green
10
11if the string contains "P" return "Purple"
12if the string contains "B" return "Blue"
13if the string contains "G" return "Green"
Sheet1
Cell Formulas
RangeFormula
B2:B9B2=IF(ISNUMBER(SEARCH("P",A2,1)),"Purple", IF(ISNUMBER(SEARCH("B",A2,1)),"Blue", IF(ISNUMBER(SEARCH("G",A2,1)),"Green", "")))
 
Upvote 0
Solution
Thank you for the quick reply, its amazing how quickly nesting gets messy lol
 
Upvote 0
yep,
I tend to use the false as a nest , rather than nest in true
but thats just me and how i prefer to see things laid out

you could use IFS() , but as that has to work out and evaulate all formulas for TRUE's i tend avoid that function
 
Upvote 0

Forum statistics

Threads
1,215,884
Messages
6,127,564
Members
449,385
Latest member
KMGLarson

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