Solved

Search for text in a string

Posted on 2014-11-18
12
75 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
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 Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

743 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

13 Experts available now in Live!

Get 1:1 Help Now