+ Reply to Thread
Results 1 to 7 of 7

FIND function help

  1. #1
    Forum Contributor
    Join Date
    07-18-2014
    Location
    Missouri, USA
    MS-Off Ver
    2010
    Posts
    175

    FIND function help

    I have model numbers that are either just seven digits or some are seven digits followed with a dash and up to 5 more characters. I have a vendor that will add three numbers to the front, then a dash, then my model number with sometimes putting a dash where is is suppose to be. Confused yet?

    If you look at the attachment, I use the following formula.....=IF(LEN(TRIM(A2))=11,TRIM(MID(A2,FIND("-",A2)+1,7)),TRIM(MID(A2,FIND("-",A2)+1,7)&"-"&RIGHT(A2,LEN(A2)-11))) but it puts in 2 dashes in the place where they actually use my dash. I understand why it does it but I don't understand how to stop it. Is there a "FIND first occurrence" and do this, and skip the next occurrence?

    Good luck and thanks for the help.
    Attached Files Attached Files

  2. #2
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: FIND function help

    Try this formula

    Looks like I totally misread the requirements.

    Corrected

    =SUBSTITUTE(IF(ISERROR(--RIGHT(TRIM(A2))),REPLACE(TRIM(RIGHT(A2,LEN(A2)-FIND("-",A2))),LEN(TRIM(RIGHT(A2,LEN(A2)-FIND("-",A2)))),,"-"),TRIM(RIGHT(A2,LEN(A2)-FIND("-",A2)))),"--","-")
    Last edited by AlKey; 10-13-2014 at 04:14 PM. Reason: Added TRIM function
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: FIND function help

    See if this works for all options

    =REPLACE(SUBSTITUTE(TRIM(MID(A2,5,100)),"-",""),8,0,IF(LEN(SUBSTITUTE(TRIM(MID(A2,5,100)),"-",""))>7,"-",""))
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: FIND function help

    I believe this will give the results you're looking for.

    =TRIM(REPLACE(SUBSTITUTE(REPLACE(A2,1,FIND("-",A2),""),"-",""),8,0,IF(LEN(TRIM(A2))>11,"-","")))

  5. #5
    Forum Contributor
    Join Date
    07-18-2014
    Location
    Missouri, USA
    MS-Off Ver
    2010
    Posts
    175

    Re: FIND function help

    Not quite AlKey but close.

    ChemistB and Jonmo1, both of these worked and thank you. I love this website.

  6. #6
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: FIND function help

    another way..

    =MID(SUBSTITUTE(A2,"-","",2),5,7)&IF(LEN(TRIM(A2))>11,"-"&RIGHT(TRIM(A2)),"")
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  7. #7
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: FIND function help

    Quote Originally Posted by Ace_XL View Post
    =MID(SUBSTITUTE(A2,"-","",2),5,7)&IF(LEN(TRIM(A2))>11,"-"&RIGHT(TRIM(A2)),"")
    That's awesome, but the substitute is actually completely unnecessary there...
    Since the MID is retrieving 7 characters beginning at 5, the 2nd - doesn't appear till the 8th character beginning at 5..
    So it's not even necessary to remove that 2nd -

    Here it is without the substitute

    =MID(A2,5,7)&IF(LEN(TRIM(A2))>11,"-"&RIGHT(TRIM(A2)),"")

+ 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. add in the parameters to the Find function to only find an exact match.
    By jakeembx in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-07-2014, 08:57 AM
  2. [SOLVED] Problem with Find function. Need to find Exact match
    By SMILE in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-06-2012, 07:07 AM
  3. find function doesnt find imported info
    By dscott2479 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 07-12-2011, 07:11 PM
  4. Replies: 2
    Last Post: 03-30-2009, 04:04 AM
  5. Using find function to find entries in multiple cells
    By stanigator in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-11-2007, 08:45 PM

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