+ Reply to Thread
Results 1 to 10 of 10

search and return a string

  1. #1
    Registered User
    Join Date
    04-11-2010
    Location
    bucharest
    MS-Off Ver
    Excel 2003
    Posts
    7

    search and return a string

    Please help me to find a formula able to return in a specific cell the 2 last numbers of a bar code only if it starts with a specified string.
    Thank you in advance!

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: search and return a string

    Might be an idea to post some examples ?

    Perhaps along the lines of:

    =IF(LEFT(barcode;2)="XX";0+RIGHT(barcode;2);"")

  3. #3
    Registered User
    Join Date
    04-11-2010
    Location
    bucharest
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: search and return a string

    ex: 1842000102346 1942000102330 2000000102338 1943000102362
    1842 represents the name of the product that I am interested in finding its measure, expressed by the last two digits - 46
    thanks

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: search and return a string

    So, adapting earlier example, assuming number in A1:

    B1: =IF(LEFT(A1;4)="1842";0+RIGHT(A1;2);"")

  5. #5
    Registered User
    Join Date
    04-11-2010
    Location
    bucharest
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: search and return a string

    Thank you for your help.
    Unfortunately I couldn't make myself clear.
    I need a formula that is able to check each code in a range and to apply your solution for the cell that contains the code which start with 1842.

    Thank you again!

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: search and return a string

    That formula does what you want. You put that formula in B1 (or wherever you want in row 1...it checks the value in A1)...then copy the cell down as far you need. The formula will adjust for each row as you copy downward.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  7. #7
    Registered User
    Join Date
    04-11-2010
    Location
    bucharest
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: search and return a string

    You are right, but I need to use the formula in a single cell.

  8. #8
    Registered User
    Join Date
    04-11-2010
    Location
    bucharest
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: search and return a string

    That cell will complete a form...

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: search and return a string

    Maybe =--RIGHT(INDEX(A1:A100, MATCH("1842", INDEX(LEFT(A1:A100, 4), 0), 0)), 2)
    Entia non sunt multiplicanda sine necessitate

  10. #10
    Registered User
    Join Date
    04-11-2010
    Location
    bucharest
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: search and return a string

    Thank you very much for your answer.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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