+ Reply to Thread
Results 1 to 4 of 4

Delimite pipe (|) separated values to single column

  1. #1
    Registered User
    Join Date
    05-20-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    4

    Delimite pipe (|) separated values to single column

    Hi All,

    I am new to vba macros. Can anybody help me with the simple vba code to perform following operation.

    I have data in two columns with multiple rows as follows:

    Column A Column B
    A A1 | A2 | A3
    B B1 | B2
    C C1 | C2 | C3 | C4
    D D1 | D2 | D3 | D4 | D5
    ...
    ......
    ........

    I need the final output in the following format:

    Column C Column D
    A A1
    A A2
    A A3
    B B1
    B B2
    C C1
    C C2
    C C3
    C C4
    D D1
    D D2
    D D3.......................
    ...
    ......
    ........

    Any help would be appreciated

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

    Re: Delimite pipe (|) separated values to single column

    'ROWS TO COLUMNS
    Here's a macro for expanding rows of data to multiple rows parsing out the delimited values in one column while duplicating all the others.Just edit the Col = 3 code to Col = 2 and run it on a copy of your data, should do what you want. There's a sample workbook too you could drop your data into and test it out.
    Last edited by JBeaucaire; 12-26-2019 at 03:48 PM.
    _________________
    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!)

  3. #3
    Registered User
    Join Date
    05-20-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    4
    Thank you for prompt response. The macro worked smoothly. However, I feel only problem with macro is that, original data gets replaced by new dataset.
    Last edited by JBeaucaire; 12-26-2019 at 03:48 PM.

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

    Cool Hi ! As a starter try this demonstration !


    PHP Code: 
    Sub Demo()
            
    L& = 1
        
    For R& = 1 To Cells(Rows.Count2).End(xlUp).Row
                 SP 
    Split(Cells(R2).Value" | ")
                 
    N& = UBound(SP) + 1
            With Cells
    (L3).Resize(N2).Columns
                 Cells
    (R1).Copy .Item(1)
                 .
    Item(2).Value Application.Transpose(SP)
                 
    N
            End With
        Next
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

+ 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. Sorting Pipe separated numbers within cell
    By sandubandu in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-01-2016, 03:44 AM
  2. Returning Multiple Values Separated by Commas to a single cell
    By enragedpigeon in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-02-2015, 05:48 PM
  3. [SOLVED] Using comma separated values in a single cell
    By joerobb in forum Excel General
    Replies: 7
    Last Post: 01-16-2015, 08:45 AM
  4. [SOLVED] Any formula for making multiple column be single column separatef by pipe?
    By irruzzz in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-15-2014, 12:19 PM
  5. Transpose single row containing semicolon separated values to column
    By Wilco84 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-04-2013, 07:50 AM
  6. [SOLVED] Count all the unique values in a cell separated by a pipe delimiter, i.e. |
    By Lija in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-10-2013, 11:16 AM
  7. CSV file with two columns multiple values separated by pipe. Need to Combine
    By nikythebest in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-01-2012, 04:30 AM

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