+ Reply to Thread
Results 1 to 11 of 11

FIND Function; looking for an array of strings and returning found string value

  1. #1
    Registered User
    Join Date
    05-04-2014
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2010
    Posts
    13

    FIND Function; looking for an array of strings and returning found string value

    Hello, good day.

    I'm dealing with a simple table of names (Last Name, First Name, Middle Name, Suffix). The Suffix column is a newly requested addition for migration into an MS SQL database. Currently, all the suffixes (Jr, Sr) are placed in the First Name column (i.e. John Jr.).

    I'm looking for a simple formula that will (a) find either "Jr." or "Sr." in the indicated cell and then (b) return that found string. Currently, this is what I have:

    =IF(ISERROR(FIND({"Jr.","Sr."},H3)),"",RIGHT(H3,LEN(H3)-FIND(" ",H3)))

    It only returns the "Jr." values. I know something's wrong. Can you help me with this? Without using another Index formula referencing two cells containing just Jr. and Sr. to combine with Match, I mean.

    I would very much appreciate it. Thank you!

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: FIND Function; looking for an array of strings and returning found string value

    Assuming K1=Jr. and K2=Sr. then try this Array Formula. Since this is an array formula so you need to confirm it with Ctrl+Shift+Enter (i.e. hold down the Ctrl+Shift and then press Enter)

    Please Login or Register  to view this content.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  3. #3
    Registered User
    Join Date
    05-04-2014
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: FIND Function; looking for an array of strings and returning found string value

    Thank you so much! Worked like a charm.

    But is there a way to do this without having Jr. and Sr. as reference strings placed outside the table? Or does this method take up less memory in the Excel file?

  4. #4
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: FIND Function; looking for an array of strings and returning found string value

    If you don't want to reference the cells having Jr. and Sr., try this......Remember to confirm with Ctrl+Shift+Enter.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-04-2014
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: FIND Function; looking for an array of strings and returning found string value

    It worked! Thank you very much! May the force be with you

  6. #6
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: FIND Function; looking for an array of strings and returning found string value

    Glad to help you. Thanks for the feedback.
    Since you are new to the forum so just to tell you that if that takes care of your question, please mark your thread as solve by selecting Thread Tools (just above your first post) --> Mark thread as solve.
    Moreover you may also click on * (star) to Add Reputation to those who have put their time and efforts to help you in this forum. This is another way to say thanks to them.

  7. #7
    Registered User
    Join Date
    05-04-2014
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: FIND Function; looking for an array of strings and returning found string value

    Done thank you again! Hope to be of help to someone else in the forum in the near future!

  8. #8
    Registered User
    Join Date
    05-04-2014
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: FIND Function; looking for an array of strings and returning found string value

    By the way -- sorry if I may seem a bit naggy -- I tried understanding the formula itself, and how it works, tracing the step by step events that occur. For self-educating purposes and future knowledge. I'm a bit lost. How does the OR function fit into the formula? It seems so integral. Does it trigger the loop into the array? It's absence (and presence) seem to be the key determinant. How?

  9. #9
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: FIND Function; looking for an array of strings and returning found string value

    The formula is evaluated step by step like this......

    Assuming that H3 = John Jr., then

    1) IF(OR(ISNUMBER(SEARCH({"Jr.","Sr."},H3))),RIGHT(H3,3),"")
    2) IF(OR(ISNUMBER({6,#VALUE!})),RIGHT(H3,3),"")
    3) IF(OR({TRUE,FALSE}),RIGHT(H3,3),"")
    4) IF(TRUE,RIGHT(H3,3),"")

    So you see that in 2nd step search finds Jr. in the cell H3 and returns 6 (its position in the string in cell H3). In the next step ISNUMBER checks whether the result obtained by the search function is a number and returns True or False in step 4. So now the observe the equation in step 3, the OR has one True and one False and evaluates to True in the step 4 because one of the logical condition is True. So once the OR returns True, RIGHT(H3,3) is evaluated.

    So what if cell H3 doesn't contains neither Jr. nor Sr. In that case the OR will have two False and will be evaluated to False and then the formula will return "" (blank) in the formula cell.

    I hope this helps.

  10. #10
    Registered User
    Join Date
    05-04-2014
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: FIND Function; looking for an array of strings and returning found string value

    Oh, I understand now. The combination of ISNUMBER and SEARCH functions work as one, in a distributive pattern (kind of like "x(x+y)"), and the results are the ones being used as OR arguments. That's what what was bugging me, how the OR was so significant.

    Thank you so much again! I appreciate the help and the additional learnings!

  11. #11
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: FIND Function; looking for an array of strings and returning found string value

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA Find Partial String in String Array and Output the Found String Array Value
    By scherich in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-02-2014, 11:20 AM
  2. Replies: 2
    Last Post: 10-12-2012, 11:38 PM
  3. [SOLVED] Find various strings and copy the found string in column A of the row it appears in.
    By equanet in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-29-2012, 02:55 PM
  4. search for a part of string within an array of strings from another array list
    By jdonohue in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-12-2011, 01:32 PM
  5. find string pos from strings in an array
    By friscokid in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-30-2008, 12:54 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1