+ Reply to Thread
Results 1 to 6 of 6

formula to take list of values (rows) and place, separated by commas in single cell?

  1. #1
    Registered User
    Join Date
    07-23-2010
    Location
    ithaca ny
    MS-Off Ver
    Excel 2007
    Posts
    40

    formula to take list of values (rows) and place, separated by commas in single cell?

    how can i write a formula to grab all cells within a selected range and combine them into one cell separated by commas?

    At small volumes i was just using =A1&","&" "&A2..... but now i need to quickly and flexibly grab any range (some of my lists will be 5 rows needing to be combined into a single cell, others will be 100 rows) and combine all the values into a single cell.

    Can someone please suggest how I can set this up?

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: formula to take list of values (rows) and place, separated by commas in single cell?

    There is no native formula to do that in Excel. I recommend a udf. Here's one from Harlan Grove
    Please Login or Register  to view this content.
    So after putting the code into a module
    =aconcat(A1:B2,",") would give the contents of A1,B1,A2,B2
    Does that work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    07-23-2010
    Location
    ithaca ny
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: formula to take list of values (rows) and place, separated by commas in single cell?

    a udf? "after putting that code into a module"?

    Sounds to me like this is working with vba? I've never worked with that before, but I'm open to trying. How do i get started to enter this code?

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: formula to take list of values (rows) and place, separated by commas in single cell?

    Yes, this is VBA and UDF stands for User Defined Function.
    ALT + F11 opens the VBA editor. Insert> Module and paste the code into the text window that opens up.
    Then close the editor (no need to save)
    Now in your workbook, give it a try
    =aconcat(A1:B2,",") or whatever your range is. If you want a space after the comma
    =aconcat(A1:B2," ,")
    Let us know if you have problems.

  5. #5
    Registered User
    Join Date
    07-23-2010
    Location
    ithaca ny
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: formula to take list of values (rows) and place, separated by commas in single cell?

    didn't get back to this project until today. Worked flawlessly. Thank you.

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: formula to take list of values (rows) and place, separated by commas in single cell?

    Now you're using UDF's. You're officially an Excel Wizard.

+ 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