Closed Thread
Results 1 to 5 of 5

Help with Excel macro/VBA converting CSV entries into multiple rows

  1. #1
    Registered User
    Join Date
    08-01-2012
    Location
    Anyville, Anywhere
    MS-Off Ver
    Excel 2007
    Posts
    11

    Help with Excel macro/VBA converting CSV entries into multiple rows

    Hi folks - I have a large spreadsheet (over 100,000 rows) with 10 columns of data. Two of the columns have comma separate value entries. I need a macro (or series of macros) that can automatically duplicate rows of data with only a single entry for each such comma separated value.

    so today I have: John | Smith | Virginia | Apples, Bananas, Grapes, Mangoes

    And I want:

    John | Smith | Virginia | Apples
    John | Smith | Virginia | Bananas
    John | Smith | Virginia | Grapes
    John | Smith | Virginia | Mangoes

    I need the macro to be "smart enough" to only create duplicate rows for the number of entries in the CSV cell. So, in my example, I had 4 fruit names. If I had 17 fruit names, I'd want 17 rows, each with a single instance of each fruit. If there are two identical fruit names, that's okay - I can live with two duplicate rows of the same exact fruit name.

    Thoughts on how to do this??

  2. #2
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Help with Excel macro/VBA converting CSV entries into multiple rows

    AirBeast,

    can you possibly post a sample spreadsheet to ensure we styart on the right track, doesnt need many rows. Can you also include the expected results when both of the csv cols have multiple entries.

    Do you expect the data to be in the current tab or can you live with a new output tab?

    jamc

  3. #3
    Registered User
    Join Date
    08-01-2012
    Location
    Anyville, Anywhere
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Help with Excel macro/VBA converting CSV entries into multiple rows

    Sure. Attaching a file with Before and After. Sure, no problem on having the output on a second sheet.
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Help with Excel macro/VBA converting CSV entries into multiple rows

    airbeast.xlsm

    AirBeast,

    Try this.

    I built it using the example data from your original post and therefore it is looking for the CSV data in Col D. In the absence of any example of the whole 10 cols I simply fudged up the data so that you can see the correct output.

    You (we) might have to look at speed if your input file is large as you say. First thing is to get it working correctly then sort out speed if required (my guess based on a similar process on 50,000 rows taking 1.15 minutes, is that it may take a 2 - 3 minutes to process 100,000 rows

    jmac

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Help with Excel macro/VBA converting CSV entries into multiple rows

    Thread posted in CS subforum, hence closed.

    Airbeast, you are duplicating efforts by posting it in both the paid and free forums. Please avoid doing so.

    Thanks,
    Admin
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Converting text strings into numerical values for multiple entries
    By exceln00bie113 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-13-2013, 10:55 AM
  2. Converting multiple columns to rows / Converting to Panel Data
    By Stuart11 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-14-2013, 05:50 AM
  3. Replies: 4
    Last Post: 06-29-2012, 05:56 AM
  4. problem converting multiple text files into excel worksheets macro
    By mehdoush in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 05-19-2012, 03:51 AM
  5. Count Multiple Entries, Return Multiple Rows, Based On 3 Criteria
    By gtj_global in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-20-2008, 06:40 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