+ Reply to Thread
Results 1 to 4 of 4

Concatenate a column of texts into chunks of 10 with VBA

  1. #1
    Registered User
    Join Date
    03-27-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Concatenate a column of texts into chunks of 10 with VBA

    Hi Everyone,

    I basically have little to no knowledge of VBA. I have a list of hundreds of names in column A starting in Cell A3 in which i want to concatenate in chunks of 10 separated by ", " in-between each cell as well as add a hyphen " - " and a specific text declared in Cell A1.

    I have to repeat this task frequently with different numbers of text so I would like for the code to run until an empty cell is detected after Cell A3. I would like to output to be in column C

    This is an example of what I want done:

    DATA IN COLUMN A
    A1: List of Names
    A2:
    A3: Lisa
    A4: John
    A5: Mary
    A6: Joe
    A7: Bill
    A8: Annie
    A9: Jane
    A10: Cindy
    A11: Larry
    A12: Aaron
    A13: Nate
    A14: Jess
    A15: Phil

    OUTPUT IN COLUMN C
    C1: Lisa, John, Mary, Joe, Bill, Annie, Jane, Cindy, Larry, Aaron - List of Names
    C2: Nate, Jess, Phil - List of Names



    I know I can use the excel formula =CONCATENATE(A3,", ",A4,", ",A5,", ",A6,", ",A7,", ",A8,", ",A9,", ",A10,", ",A11,", ",A12," - ",A1) for the first output, but this will be very time consuming and I don't know how long the list of names will be in the future. Any help would be appreciated!

  2. #2
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Concatenate a column of texts into chunks of 10 with VBA

    How about:

    Please Login or Register  to view this content.
    Gary's Student

  3. #3
    Registered User
    Join Date
    03-27-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Concatenate a column of texts into chunks of 10 with VBA

    This is great! Thank you. One more question... instead of having " - List of Names" embedded in the code, can I have it as " - " & A1.

    Basically, The text in A1 will change every time that needs to be inputted after the hyphen so I would prefer not to have "List of Names" embedded in the code.

  4. #4
    Registered User
    Join Date
    03-27-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Concatenate a column of texts into chunks of 10 with VBA

    Quote Originally Posted by annabellesays View Post
    This is great! Thank you. One more question... instead of having " - List of Names" embedded in the code, can I have it as " - " & A1.

    Basically, The text in A1 will change every time that needs to be inputted after the hyphen so I would prefer not to have "List of Names" embedded in the code.

    Nevermind I got it! I changed it to " - " & Range("A1")

    Thanks again!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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