Solved

Search for text in a string

Posted on 2014-11-18
12
79 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
  • 4
  • 3
  • 3
  • +1
12 Comments
 
LVL 29

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 earned 500 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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 29

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 29

Expert Comment

by:gowflow
ID: 40449238
ok fine but I don't understand what is the problem now
gowflow
0
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
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 29

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

808 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