Using this barcode to split data into columns (pharmacy related)
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Using this barcode to split data into columns (pharmacy related)
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Jul 2019
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Using this barcode to split data into columns (pharmacy related)

    Hello everyone!

    I'm a pharmacy student working on how to extract numbers from medication QR codes into individualized columns in Excel.

    For example, this code
    010030093552606517201130101040951182110091947809740 needs to put into 3 columns: GTIN, Lot, and Expiry date. GTIN is donated by 01 in front and has a 14 fixed digit. Lot number is denoted by 10 and the digits may vary (its not fixed so that is why we were having trouble). Expiry date is denoted by 17 and its fixed at 6 digits.

    I have tried the following code: =LEFT(MID(A1,SEARCH("17",A1)+2,LEN(A1)),FIND("21"-1,MID(A1,SEARCH("17",A1)+2,LEN(A1)))-1)

    This is an screenshot of what I'm working towards: https://paste.pics/0d7ee6a250f7a17721281285a2985621
    This is more information on the code: https://paste.pics/7622d1f5f0708387defb889dab03198b

    Any advice is helpful. Thank you!!!

  2. #2
    Board Regular sykes's Avatar
    Join Date
    May 2002
    Location
    Cornwall,England
    Posts
    1,560
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Using this barcode to split data into columns (pharmacy related)

    Is the GTIN always first, and the Exp date always second?
    Sykes
    Windows 10 / XL 2016
    Members don't have crystal balls, so PLEASE describe your situation, code,
    and requirements ACCURATELY in your first post. It saves hair!
    Better still - upload your spreadsheet (and formulae!) with this great bit of kit.


    - forum use guidelines, forum rules and terms of use
    - Try searching for your answer first, see how
    - Read the FAQs
    - List of BB codes

  3. #3
    Board Regular sykes's Avatar
    Join Date
    May 2002
    Location
    Cornwall,England
    Posts
    1,560
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Using this barcode to split data into columns (pharmacy related)

    If the GTIN's always first, then that one's easy: =MID(A1,3,14)
    If the Exp date's always second, then that one's easy: =MID(A1,19,6)

    Not at all sure about retrieving the Lot# - bearing in mind that both it, AND the serial number can be up to 20 characters each!
    You can use INSTR and INSTRREV etc, but to try and pick them out of a "Random" string will (I think) need a bit more info on any more reliable constants
    Sykes
    Windows 10 / XL 2016
    Members don't have crystal balls, so PLEASE describe your situation, code,
    and requirements ACCURATELY in your first post. It saves hair!
    Better still - upload your spreadsheet (and formulae!) with this great bit of kit.


    - forum use guidelines, forum rules and terms of use
    - Try searching for your answer first, see how
    - Read the FAQs
    - List of BB codes

  4. #4
    New Member
    Join Date
    Jul 2019
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Using this barcode to split data into columns (pharmacy related)

    Yes, the order would be GTIN, Expiry, and then LOT number.

  5. #5
    New Member
    Join Date
    Jul 2019
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Using this barcode to split data into columns (pharmacy related)

    The GTIN and Exp worked perfectly! Thank you so much.

    I'm not sure what INSTR OR INSTERREV are or how to use them.

    What more information do you need for the Lot number?

  6. #6
    New Member
    Join Date
    Jul 2019
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Using this barcode to split data into columns (pharmacy related)

    Quote Originally Posted by sykes View Post
    If the GTIN's always first, then that one's easy: =MID(A1,3,14)
    If the Exp date's always second, then that one's easy: =MID(A1,19,6)

    Not at all sure about retrieving the Lot# - bearing in mind that both it, AND the serial number can be up to 20 characters each!
    You can use INSTR and INSTRREV etc, but to try and pick them out of a "Random" string will (I think) need a bit more info on any more reliable constants


    Yes, the order would be GTIN, Expiry, and then LOT number followed by serial number (but I don't need the serial number)

  7. #7
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    25,610
    Post Thanks / Like
    Mentioned
    445 Post(s)
    Tagged
    45 Thread(s)

    Default Re: Using this barcode to split data into columns (pharmacy related)

    How about
    =LEFT(MID(A1,27,LEN(A1)),FIND("21",MID(A1,27,LEN(A1)))-1)
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  8. #8
    New Member
    Join Date
    Jul 2019
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Using this barcode to split data into columns (pharmacy related)

    Quote Originally Posted by pharmavenger View Post
    Yes, the order would be GTIN, Expiry, and then LOT number followed by serial number (but I don't need the serial number)
    I'm sorry, I would like to correct something, the order of the barcode is GTIN, Serial, Expiry, and then Lot

  9. #9
    MrExcel MVP Rick Rothstein's Avatar
    Join Date
    Apr 2011
    Location
    New Jersey, USA
    Posts
    34,974
    Post Thanks / Like
    Mentioned
    91 Post(s)
    Tagged
    33 Thread(s)

    Default Re: Using this barcode to split data into columns (pharmacy related)

    Do these formulas do what you want (they are based on the picture you posted in the first link in your first message)...

    GTIN: =MID(A2,3,14)

    Lot: =MID(A2,LEN(B2)+LEN(C2)+9,7)

    Expiry: =MID(A2,19,6)

    Note: The above formulas assume your barcode number is in cell A2 and the the GTIN is to be in cell B2, the Lot number is to be in cell C2 and the Expiry is to be in cell D2.
    Last edited by Rick Rothstein; Jul 19th, 2019 at 03:39 PM.
    Rick's "mini" blog... http://www.excelfox.com/forum/f22/
    .
    Want to post a small screen shot? See Part B here.

  10. #10
    New Member
    Join Date
    Jul 2019
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Using this barcode to split data into columns (pharmacy related)

    Quote Originally Posted by Rick Rothstein View Post
    Do these formulas do what you want (they are based on the picture you posted in the first link in your first message)...

    GTIN: =MID(A2,3,14)

    Lot: =MID(A2,LEN(B2)+LEN(C2)+9,7)

    Expiry: =MID(A2,19,6)

    Note: The above formulas assume your barcode number is in cell A2 and the the GTIN is to be in cell B2, the Lot number is to be in cell C2 and the Expiry is to be in cell D2.
    The GTIN formula works perfectly! The Lot and Expiry formulas do not work. A2 will have the barcode number and from there I'm trying to derive the GTIN, LOT, and expiry. The GTIN number comes first (14 characters, its fixed), then serial, expiry (6 characters) and lot. Serial and Lot don't have fixed characters.

    This is what I got using those formulas: https://paste.pics/26670cb31094b6f2a62e10c833513ade

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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