+ Reply to Thread
Results 1 to 7 of 7

IF Loop to Separate Names

  1. #1
    Registered User
    Join Date
    09-23-2010
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    23

    Smile IF Loop to Separate Names

    Hi,

    I have a deadline to meet and need to put this together quick.

    Column A has a list of serial numbers.

    Next to every serial number (Column B), are several names separated by semi-colons.

    Example:
    456789 john; mary; bob
    343400 gary, frank
    230200 fisher; john; harry; ron
    545777 john

    I would like to make a macro that takes the names in column B and separates them line by line. There will always be a semicolon separating the names.

    Result:
    456789 john
    456789 mary
    456789 bob
    343400 gary
    343400 frank
    etc

    Please help? I don't know where to start.
    Thanks!

  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: IF Loop to Separate Names. Please assist.

    '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.
    _________________
    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
    09-23-2010
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: IF Loop to Separate Names. Please assist.

    Thanks for the quick reply!

    I got an error trying to access the site though. Can you please post another link?

    I looked into the URL and played around with it to get it to work

    https://sites.google.com/a/madrocket...ows-to-columns
    Last edited by JBeaucaire; 12-27-2019 at 10:53 PM.

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

    Re: IF Loop to Separate Names. Please assist.

    Quote Originally Posted by contra76 View Post
    Thanks for the quick reply!

    I got an error trying to access the site though. Can you please post another link?

    I looked into the URL and played around with it to get it to work

    https://sites.google.com/a/madrocket...ows-to-columns
    That's the correct link, I clicked it in your post above and in mine and both work fine.
    Last edited by JBeaucaire; 12-27-2019 at 10:54 PM.

  5. #5
    Registered User
    Join Date
    09-23-2010
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    23

    Re: IF Loop to Separate Names

    Works like a charm.

    Hate to be difficult but what if there are semicolons at the end sometimes?

    For example sometimes it would look like:
    456789 john; mary; bob;
    343400 gary, frank;
    230200 fisher; john; harry; ron;
    545777 john

    So the first three rows would make an extra row which would be blank but the last would not.

    Code I'm using:
    Please Login or Register  to view this content.

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

    Re: IF Loop to Separate Names

    The code has a series of "parsing" tests, the last one being just "spaces". With your data, I'd do a search/replace on that column and just remove all the semicolons.

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

    Re: IF Loop to Separate Names

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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