Solved

Search for text in a string

Posted on 2014-11-18
12
77 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:
teylyn 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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:teylyn
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

932 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now