+ Reply to Thread
Results 1 to 11 of 11

Need Macro To Create New Rows Based on Comma Separted Values in Cell

  1. #1
    Registered User
    Join Date
    12-08-2015
    Location
    Fairfield,Iowa
    MS-Off Ver
    2010
    Posts
    11

    Need Macro To Create New Rows Based on Comma Separted Values in Cell

    I will start with a spreadsheet where one or more of the columns has commas in the cells.
    I want to be asked which column has the values that will be broken out into new rows.
    Any other cells in the same row should be repeated for the new rows.
    In this case, it is column B, but it can vary depending on the spreadsheet.

    Before
    A B
    Tommy Student
    Harry Bartender, Video store clerk
    Sally Waitress

    After
    A B
    Tommy Student
    Harry Bartender
    Harry Video store clerk
    Sally Waitress[/B]
    Attached Files Attached Files

  2. #2
    Forum Contributor Jack7774's Avatar
    Join Date
    08-31-2012
    Location
    Georgia, US
    MS-Off Ver
    Excel 2010
    Posts
    576

    Re: Need Macro To Create New Rows Based on Comma Separted Values in Cell

    This won't work for a cell value that has two or more commas though.

    Please Login or Register  to view this content.
    Thank those who have helped you by clicking the Star * below their name and please mark your post [SOLVED] if it has been answered satisfactorily.

  3. #3
    Registered User
    Join Date
    12-08-2015
    Location
    Fairfield,Iowa
    MS-Off Ver
    2010
    Posts
    11

    Re: Need Macro To Create New Rows Based on Comma Separted Values in Cell

    Thanks, but my data has more than two commas.

  4. #4
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Need Macro To Create New Rows Based on Comma Separted Values in Cell

    This will work with any number of commas. You can input a column letter or number, doesn't matter. Also assumed your data has a comma followed by a space as your example shows, not just commas.

    E.g. A, B

    not

    A,B

    Please Login or Register  to view this content.
    I'm interested in starting a career working with VBA, if anyone knows of any opportunities!

  5. #5
    Registered User
    Join Date
    12-08-2015
    Location
    Fairfield,Iowa
    MS-Off Ver
    2010
    Posts
    11

    Re: Need Macro To Create New Rows Based on Comma Separted Values in Cell

    Thanks, looks good, but when I ran it, I got "Variable not defined."

  6. #6
    Registered User
    Join Date
    12-08-2015
    Location
    Fairfield,Iowa
    MS-Off Ver
    2010
    Posts
    11

    Re: Need Macro To Create New Rows Based on Comma Separted Values in Cell

    I added the Dim statements and it works great.
    One last request. How easy would it be to have the data to a new sheet.

  7. #7
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Need Macro To Create New Rows Based on Comma Separted Values in Cell

    Ha, small world, I grew up south of Davenport.

    For new sheet:

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    12-08-2015
    Location
    Fairfield,Iowa
    MS-Off Ver
    2010
    Posts
    11

    Re: Need Macro To Create New Rows Based on Comma Separted Values in Cell

    I get sheet named Output and a number, but no data.

    Nice state. Moved here in 2013 from Washington DC. No traffic...yeah!

  9. #9
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Need Macro To Create New Rows Based on Comma Separted Values in Cell

    Can you post a sample workbook that it's not working on? It works as expected for me on your original worksheet you posted.

  10. #10
    Registered User
    Join Date
    12-08-2015
    Location
    Fairfield,Iowa
    MS-Off Ver
    2010
    Posts
    11

    Re: Need Macro To Create New Rows Based on Comma Separted Values in Cell

    I don't know what I was doing wrong, but now it works.
    I suspect I had an extra row above the data and that was throwing it off.

    Thanks again. BRAVO!!

  11. #11
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Need Macro To Create New Rows Based on Comma Separted Values in Cell

    Glad to help. Please mark this thread SOLVED, and any reputation points (the * in the lower left of the posts) are appreciated.

+ 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. Replies: 9
    Last Post: 02-04-2016, 08:23 AM
  2. Macro to create a list of sheets, separated with comma in a single cell
    By manolomana in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-30-2014, 11:00 AM
  3. [SOLVED] Macro to Create Message box based on cell values
    By aneshdas in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 12-20-2013, 05:24 PM
  4. Create Auto-Calculating Cell and Assign Cell Values Based on a Macro
    By Titanium Fox in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-26-2013, 12:00 AM
  5. [SOLVED] Splitting cell contents based on Comma and inserting new rows below it.
    By SS113 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-22-2013, 09:09 AM
  6. need macro to create multiple rows based on cell qty
    By ajschultui in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-02-2013, 03:57 AM
  7. Comma separted values
    By Divinite in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-09-2007, 11:57 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