?
Solved

Search for text in a string

Posted on 2014-11-18
12
Medium Priority
?
85 Views
Last Modified: 2014-11-19
Could an Expert provide the answer to this please. I need to search a string of text and find one of several words.

i.e. I need to find Jan or Feb or Mar or Apr

I have the below formula but cannot figure out how to expand this to look for all of the above.

=IF(ISERROR(SEARCH("Jan",A1)),"","Jan")

Thanks
0
Comment
Question by:Jagwarman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +1
12 Comments
 
LVL 31

Expert Comment

by:gowflow
ID: 40449198
Try this
=IFERROR(MID("JanFebMarApr",FIND(A1,"JanFebMarApr",1),3),"")

gowflow
0
 

Author Comment

by:Jagwarman
ID: 40449202
Hi gowflow I get a blank in the cell and in the formula window #Value
0
 
LVL 50

Accepted Solution

by:
Ingeborg Hawighorst (Microsoft MVP / EE MVE) earned 2000 total points
ID: 40449212
Hello,

I'd keep it simple and just concatenate the four different searches.

=IF(ISERROR(SEARCH("Jan",A1)),"","Jan")&IF(ISERROR(SEARCH("Feb",A1)),"","Feb")&IF(ISERROR(SEARCH("Mar",A1)),"","Mar")&IF(ISERROR(SEARCH("Apr",A1)),"","Apr")

cheers, teylyn
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Jagwarman
ID: 40449217
Thanks teylyn that is brilliant.

I cant "accept" on this PC will do that later from home.
0
 
LVL 31

Expert Comment

by:gowflow
ID: 40449222
Sorry small mistake from my part
=IF(A1<>"",IFERROR(MID("JanFebMarApr",SEARCH(A1,"JanFebMarApr",1),3),""),"")

gowflow
0
 

Author Comment

by:Jagwarman
ID: 40449233
It's still the same gowflow but the solution from teylyn works for me but thanks for trying
0
 
LVL 31

Expert Comment

by:gowflow
ID: 40449238
ok fine but I don't understand what is the problem now
gowflow
0
 
LVL 50
ID: 40449244
gowflow, can you explain your approach? I think you are searching in the wrong direction. As I understand it, cell A1 has some text, and it may contain any one of the month names in question, among other text.  So Find() or Search() need to look in A1 for any of the values Jan, Feb, Mar, Apr, and if found, return the respective text string.

Your formula takes the value of A1 and tries to find it in the sting "JanFebMarApr" and then returns the respective text string. But if A1 contains only the text, we get the same result with

=A1

cheers, teylyn
0
 
LVL 31

Expert Comment

by:gowflow
ID: 40449249
Teylyn
As always you are great. I totally missed the boat here !!! tks for clarifying and sorry for Jagwarman for having you frustrated with my off-solution !

gowflow
0
 
LVL 18

Expert Comment

by:krishnakrkc
ID: 40449450
For 12 months

=IFERROR(INDEX({"Jan";"Feb";"Mar";"Apr";"May";"Jun";"Jul";"Aug";"Sep";"Oct";"Nov";"Dec"},MATCH(A1,{"Jan";"Feb";"Mar";"Apr";"May";"Jun";"Jul";"Aug";"Sep";"Oct";"Nov";"Dec"},0)),"")

Kris
0
 
LVL 18

Expert Comment

by:krishnakrkc
ID: 40449451
Please disregard my post
0
 
LVL 18

Expert Comment

by:krishnakrkc
ID: 40449453
I midread the question earlier. Here is a revised one.

=IFERROR(LOOKUP(9.999E+307,SEARCH({"Jan";"Feb";"Mar";"Apr";"May";"Jun";"Jul";"Aug";"Sep";"Oct";"Nov";"Dec"},A1),{"Jan";"Feb";"Mar";"Apr";"May";"Jun";"Jul";"Aug";"Sep";"Oct";"Nov";"Dec"}),"")

Kris
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question