excel formula return text

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Excel Training and help » Excel Formula to return text when a cell contains certain text

Excel Formula to return text when a cell contains certain text

resolvedResolved · Medium Priority · Version 365

Joshua has attended:
Excel Introduction course
Excel Intermediate course
Excel Advanced course

Excel Formula to return text when a cell contains certain text

Good Morning

I am trying to think of a formula to perform the function of the above.

I am trying to group US states for example if a cell contains NC,SC or GA then then the answer will appear as South East.

Any thoughts of advise?

Thank you

Josh

RE: Excel Formula to return text when a cell contains certain te

Hello Joshua,

Thank you for your question. The best formula to achieve this is using XLOOKUP.

You can write it as follows:

=XLOOKUP(B2,$E$2:$E$51,$F$2:$F:$51)

where B2 (the lookup value) holds the state code in the line item, column E (the lookup array) holds all the state codes and column F (the return array) holds all the corresponding regions.

E F
NC South East
SC South East
NY North East

I hope this helps.

Kind regards
Marius Barnard
STL


 

Excel tip:

Line breaks in a cell

You can control the line breaks for multiple-line headings or labels in your Microsoft Excel worksheet, just like you do in Microsoft Word. Here's how to do it.

Click the cell where you want the label or heading to appear.
Type the first line of information.
Press ALT+ENTER.

View all Excel hints and tips


Server loaded in 0.1 secs.