+ Reply to Thread
Results 1 to 6 of 6

Substitute alphanumeric string into a comma separated string

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-17-2012
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    150

    Substitute alphanumeric string into a comma separated string

    Hello,

    Is there a way convert the following,

    I have this alphanumeric string in a cell: / 974974 TE / 232839 SW / 232837 CA / 232838 SA
    and need this: 974974,232839,232837,232838

    I tried SUBSTITUTE, but I am still left with the characters.

    Thanks.

  2. #2
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,939

    Re: Substitute alphanumeric string into a comma separated string

    please give some more examples so that it is easy to understand your requirement
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  3. #3
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,077

    Re: Substitute alphanumeric string into a comma separated string

    Not much to go on with just one item of test data

    So this DEFINITELY works on the example you've provided.

    =MID(A1,3,6)&","&MID(A1,15,6)&","&MID(A1,27,6)&","&MID(A1,39,6)

    You may find this doesnt work on other data in which case you'll need to supply any variations of your initial example but you should have realised that in the first place.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  4. #4
    Forum Contributor
    Join Date
    06-17-2012
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    150

    Re: Substitute alphanumeric string into a comma separated string

    Sorry for not providing enough details. Every day I receive an automated email generated by an inventory system that collects items running low. As this system detects an item running low throughout the day, it adds them to this string and separates them with a "/". At 12 AM it sends me an email with the collected items. These emailed strings do not contain the entire item description (only the ID and the first two characters of their name). I need to pull those numbers and run a query to understand what are the products running low. Therefore, the need for the comma separated "new" string containing only numbers (not characters).
    Also, every day I receive a different collection of items. For example,
    Monday's email: / 97497 TR / 23239 SW / 23837 CA / 23838 SA / 23735 SS / 24387 BA / 224577 OR / 23772 OG
    Tuesday's email: / 22094 LH / 22120 UL
    Wednesday's email: / 8608 MO / 86020 MT / 80998 MN / 8609 MH / 81156 ML / 86160 MY / 83661 MI
    In other words, the numeric portion of the string could be located anywhere in these strings.

    Thanks again for your help. I hope this clarifies my situation a little better.
    Last edited by icyrius; 06-07-2017 at 12:26 PM.

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,767

    Re: Substitute alphanumeric string into a comma separated string

    Function get_Numbers(Lstring As String) As String
    
    Dim LArray() As String
    outstr = ""
    tempstr = ""
    LArray = Split(Lstring, "/")
    
    For i = 1 To UBound(LArray)
        tempstr = Replace(LArray(i), " ", "")
        tempstr = Left(tempstr, Len(tempstr) - 2)
        outstr = outstr & tempstr & ","
    Next i
    
    get_Numbers = Left(outstr, Len(outstr) - 1)
    
    End Function
    =get_Numbers(A1)
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    06-17-2012
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    150

    Re: Substitute alphanumeric string into a comma separated string

    Wow!!! This is fantastic. I love it. Thank you so much!!!

+ 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. [SOLVED] Comma separated string element count
    By icyrius in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-30-2017, 10:58 AM
  2. [SOLVED] Extract Numbers from Comma-Separated String
    By k64 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-17-2017, 06:30 PM
  3. [SOLVED] How to extract words from a text string separated by comma
    By shukla.ankur281190 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-22-2015, 04:16 AM
  4. [SOLVED] Find the Position of String in a comma separated cell
    By Praveenk in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-15-2015, 07:27 AM
  5. Formula help on comma separated String data?
    By JGTExcel in forum Excel General
    Replies: 5
    Last Post: 02-10-2012, 01:05 PM
  6. Formula help on comma separated String data?
    By JGTExcel in forum Excel General
    Replies: 1
    Last Post: 02-09-2012, 03:33 AM
  7. Comma separated string
    By ESF in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-20-2011, 06:39 AM

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