+ Reply to Thread
Results 1 to 7 of 7

Extracting numbers from a comma separated list for use in a lookup- formula solution

  1. #1
    Registered User
    Join Date
    11-26-2012
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    8

    Extracting numbers from a comma separated list for use in a lookup- formula solution

    In MS Excel, a List of commas separated numbers
    In a column, I have a text string number list ( up to four numbers) that represent row numbers in a table ( 'MyTable' in another worksheet). These numbers are entered by a user, that looks like the example list below:

    23,234,2,16

    The Goal using MS Excel
    My goal, in the next column, is to perform and concatenate a lookup of each row number in the above list from a table.
    E.g. Vlookup(23,MyTable,2,)&Vlookup(234,MyTable,7,) etc.

    My question: The Challenge :-)
    In excel, I need a formula to extract from the comma separated list above, each number in turn and use it as the lookup value in a series of concatenated VLOOKUP formulas as shown above. The list can contain between one and four numbers.

    Any help will be much appreciated :-)

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,278

    Re: Extracting numbers from a comma separated list for use in a lookup- formula solution

    What determines the column for the VLOOKUP to return? you have 2 and 7 - what would the third and fourth numbers use?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    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
    28,137

    Re: Extracting numbers from a comma separated list for use in a lookup- formula solution

    You can obtain the individual numbers in separate columns by using "Data" ==>"Text to Columns" with comma as delimiter.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,278

    Re: Extracting numbers from a comma separated list for use in a lookup- formula solution

    Here's how to extract the four numbers:

    =LEFT(A1,FIND(",",A1)-1)
    =TRIM(MID(SUBSTITUTE(A1,",",REPT(" ",99)),98,98))
    =TRIM(MID(SUBSTITUTE(A1,",",REPT(" ",99)),98*2,98))
    =TRIM(MID(SUBSTITUTE(A1,",",REPT(" ",99)),98*3,98))

    Use these in each of the VLOOKUP statements.

  5. #5
    Registered User
    Join Date
    11-26-2012
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Extracting numbers from a comma separated list for use in a lookup- formula solution

    You are clearly an Excel Goddess, thank you

    Now, the only slight issue I have is, if a user enters a comma separated list like:

    1,234,456,789

    Excel rather unhelpfully (but with no doubt good intentions), makes the entry an integer which your amazing solution above can't handle. Is there a way to force Excel to not treat the list as a number?

  6. #6
    Registered User
    Join Date
    11-26-2012
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Extracting numbers from a comma separated list for use in a lookup- formula solution

    I think I just sorted it- I used TEXT(A1,"#,#") function in place of just A1. It now all works.

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,278

    Re: Extracting numbers from a comma separated list for use in a lookup- formula solution

    If these figures are being entered directly into Excel, then why not get the operative to use the tab key instead of the comma? It would make the whole thing much more straightforward. Better to use Excel correctly rather than try to bend Excel to your will.

    Glad to have helped.
    Last edited by AliGW; 10-17-2017 at 07:34 AM.

+ 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. How to lookup a value in one column to create a comma separated list
    By powersml07 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-05-2018, 02:16 PM
  2. Formula for creating a comma separated value from a list
    By Special-K in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-31-2017, 05:57 AM
  3. [SOLVED] Extracting information from a comma separated list of values in one cell
    By cardiff in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-11-2012, 09:17 PM
  4. Comma separated list with vertical lookup
    By tamxc4 in forum Excel General
    Replies: 0
    Last Post: 04-13-2012, 11:05 AM
  5. Replies: 6
    Last Post: 12-17-2011, 04:58 AM
  6. Replies: 1
    Last Post: 11-10-2011, 12:57 PM
  7. help extracting comma separated data
    By tn80 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-07-2008, 11:30 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