+ Reply to Thread
Results 1 to 14 of 14

Extracting delimited values in Cells into a single value per cell column?

  1. #1
    Forum Contributor
    Join Date
    10-10-2018
    Location
    Calgary, Canada
    MS-Off Ver
    2016
    Posts
    214

    Extracting delimited values in Cells into a single value per cell column?

    Hi there,

    I know the brute force way of doing this, I'm looking for an elegant way of doing this.

    Problem:

    Column A has semi-colon delimited values:

    John;Jane;Jack
    Jonah;John;Jane
    Jeff;Jill;Jack

    I want to extract these values and put it into another worksheet with only a single value in each cell, and all values unique:

    John
    Jane
    Jack
    Jonah
    Jeff
    Jill

    Now of course, I could go row by row and just use text functions to extract the names one by one, dump them (with duplicates) into a column, then use a filter function to remove the duplicates - but this is a "brute force" method and I was wondering if there was a faster more elegant way?

    For example, there is a TEXTJOIN function, that joins values in cells into a comma delimited text. Is there an opposite function of TEXTJOIN, where given a delimiter it will divide into individual values?

    Thanks!!
    Last edited by superlative; 05-15-2019 at 11:42 PM.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    Hi !

    Different ways like using a worksheet function and a dynamic array or a Collection or a Dictionary or …

  3. #3
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Extracting delimited values in Cells into a single value per cell column?

    Hi
    you could use a macro
    this once lists all names in the selected cells into sheet 2 start at cell A1

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    10-10-2018
    Location
    Calgary, Canada
    MS-Off Ver
    2016
    Posts
    214

    Re: Extracting delimited values in Cells into a single value per cell column?

    Hi there,

    I found out that the function I'm looking for is:
    objRange1.TextToColumns _
    Destination:=Range("B1"), _
    DataType:=xlDelimited, _
    Tab:=False, _
    Semicolon:=True, _
    Comma:=False, _
    Space:=False, _
    Other:=False, _
    OtherChar:="-"

    This will split all the values into individual cells in different columns (if 3 delimited values, will create 3 columns). However, I can merge all the columns by appending the columns to one another and then using a filter to remove duplicates. I think that's the fastest way??

    Thanks!
    Last edited by superlative; 05-16-2019 at 12:02 AM.

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Extracting delimited values in Cells into a single value per cell column?


    So you choose the brute force … Fast enough as it's Excel inner features.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,666

    Re: Extracting delimited values in Cells into a single value per cell column?

    Try
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    10-10-2018
    Location
    Calgary, Canada
    MS-Off Ver
    2016
    Posts
    214

    Re: Extracting delimited values in Cells into a single value per cell column?

    After further testing, this is the code that works:
    Please Login or Register  to view this content.
    the previous code using TextToColumns is garbage. You cannot set the Destination in another worksheet - it insists on writing to the same worksheet, so it's useless. Frustrated.

  8. #8
    Forum Contributor
    Join Date
    10-10-2018
    Location
    Calgary, Canada
    MS-Off Ver
    2016
    Posts
    214

    Re: Extracting delimited values in Cells into a single value per cell column?

    Quote Originally Posted by jindon View Post
    Try
    Please Login or Register  to view this content.
    That code looks very elegant, but how do I add the output to another worksheet? Let's say we call the Worksheet "Results", what is the syntax? Thanks!

  9. #9
    Forum Contributor
    Join Date
    10-10-2018
    Location
    Calgary, Canada
    MS-Off Ver
    2016
    Posts
    214

    Re: Extracting delimited values in Cells into a single value per cell column?

    I got it!! This is the code (Thanks Everyone, especially Jindon for the help!):

    Please Login or Register  to view this content.
    Only thing though - the first cell in "Results" (A1) is blank. Anyway to avoid having a blank first value? Thanks!!!

  10. #10
    Forum Contributor
    Join Date
    10-10-2018
    Location
    Calgary, Canada
    MS-Off Ver
    2016
    Posts
    214

    Re: Extracting delimited values in Cells into a single value per cell column?

    I'm almost there... The code above works if the values start in cell A1, but how do I change the syntax so it reads from some column of worksheet "Input Values" ? Thanks!

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,666

    Re: Extracting delimited values in Cells into a single value per cell column?

    1) change a1 to a2
    2) change Sheets.Add to Sheets("results")

    This is from phone so might have typo etc.

  12. #12
    Forum Contributor
    Join Date
    10-10-2018
    Location
    Calgary, Canada
    MS-Off Ver
    2016
    Posts
    214

    Re: Extracting delimited values in Cells into a single value per cell column?

    okay, this is the syntax I was looking for that sort of works:

    x = Split(Join(Application.Transpose(SWS.Range(ColumnLet & FirstRow, SWS.Range(ColumnLet & Rows.Count).End(xlUp)).Value), ";"), ";")

    It works for the time being, but I am not able to figure out the syntax for specifying the LastRow in the range. I am forced to use Rows.Count. If for example I set LastRow (in place of "Rows.Count")= 3, and there are no values in Row 4, then the code works. But if there is a value like "Frank" in row 4, then the code fails.

    So in other words, so long as I make sure that the Column ONLY contains values I want, then the code above works. But if I want to specify the LastRow of the range I want, I can't figure out how to do it. Thanks!
    Last edited by superlative; 05-16-2019 at 01:44 AM.

  13. #13
    Forum Contributor
    Join Date
    10-10-2018
    Location
    Calgary, Canada
    MS-Off Ver
    2016
    Posts
    214

    Re: Extracting delimited values in Cells into a single value per cell column?

    Okay got it: this is the syntax that works!:
    x = Split(Join(Application.Transpose(SWS.Range(ColumnLet & FirstRow, ColumnLet & LastRow).Value), ";"), ";")

    where SWS is the Worksheet we are copying from

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,666

    Re: Extracting delimited values in Cells into a single value per cell column?

    OK, this just deal with the cells in Col.A that have value, ignores blanks.
    Please Login or Register  to view this content.

+ 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] distribution of values from single cell to multiple cells in single column
    By WhatsGig in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 08-29-2017, 02:30 PM
  2. Replies: 2
    Last Post: 06-16-2016, 08:09 PM
  3. Formula for extracting text values from single cell
    By viber52 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 07-27-2015, 12:42 PM
  4. Replies: 2
    Last Post: 02-25-2015, 08:26 PM
  5. Sum values based on multiple criteria (comma delimited) in a single cell
    By leem888 in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 01-07-2011, 02:49 PM
  6. extracting values from a single cell
    By zobufeja in forum Excel General
    Replies: 2
    Last Post: 08-01-2010, 11:44 AM
  7. Replies: 5
    Last Post: 07-03-2006, 10:19 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