+ Reply to Thread
Results 1 to 18 of 18

Converting a Single Column to a Row with Commas?

  1. #1
    Registered User
    Join Date
    06-26-2012
    Location
    tx
    MS-Off Ver
    Excel 2010
    Posts
    17

    Converting a Single Column to a Row with Commas?

    Hi All,

    I'm new here and am looking for some basic help. I've been searching and I'm sure this is much easier than I'm finding.

    I have a long column with a list of #'s. What formula would I use to make it a single row separated by commas?

    Example:

    Column A1:
    1
    2
    3
    4
    5

    I want it to read 1,2,3,4,5

    I know there is a formula that looks something like this:
    =A1&","&A2&","&A3&","&A4&","... etc

    or
    =concatenate(A1,",",A2,",",A3,",",A4,","... etc

    My question is, if I have 50 numbers in a column, how could I generate this without having to type out the &"," for each one? I tried dragging it down, but that didn't work. I know nothing about VBA and this will be with random spreadsheets, so I'm not looking to do anything with macros. I'm trying to create a tutorial for my staff for this formula when they need to use it (so that they can apply it to any situation and just replace the column info if needed).

    Whew! I hope I made sense. I'm really looking for a 101, basic formula.
    Thanks SOOOOO much in advance!

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Converting a Single Column to a Row with Commas?

    Hi,

    In B1
    =A1
    In B2 and copied down
    =B1&","&A2

    Then copy the last cell in column B and paste it back as a value.

    Regards
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Converting a Single Column to a Row with Commas?

    Hello and welcome to the forum,

    There is probably a really good formula to do this in one cell but I use a helper column. It goes like this:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Also I could whip up a user-defined function if you want.

    Let me know.

    Good luck.

    abousetta
    Last edited by abousetta; 06-26-2012 at 05:24 PM. Reason: Removed extra space in formula
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  4. #4
    Registered User
    Join Date
    06-26-2012
    Location
    tx
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Converting a Single Column to a Row with Commas?

    Quote Originally Posted by Richard Buttrey View Post
    Hi,

    In B1
    =A1
    In B2 and copied down
    =B1&","&A2

    Then copy the last cell in column B and paste it back as a value.

    Regards
    Hi Richard,

    Thank you for your reply. I'm going to sound like an idiot but what do you mean by copy the last cell in column B and paste it back as a value? Also- once I do that, how do I I make it apply to all of the cells that I want to include? Again, thank you so much.

  5. #5
    Registered User
    Join Date
    06-26-2012
    Location
    tx
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Converting a Single Column to a Row with Commas?

    Quote Originally Posted by abousetta View Post
    Hello and welcome to the forum,

    There is probably a really good formula to do this in one cell but I use a helper column. It goes like this:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Also I could whip up a user-defined function if you want.

    Let me know.

    Good luck.

    abousetta
    abousetta,
    Thank you for your reply! I'm trying to understand a helper formula, how do you apply what you pasted above? I would greatly appreciate a user-defined function. Thank you so again! I never thought that a simple thing could turn out so complicated! LOL :D

  6. #6
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Converting a Single Column to a Row with Commas?

    nevermind this......
    Attached Files Attached Files
    Last edited by vlady; 06-26-2012 at 08:24 PM.
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  7. #7
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Converting a Single Column to a Row with Commas?

    Here is an example with a user-defined function.

    Hope this helps.

    abousetta
    Attached Files Attached Files
    Last edited by abousetta; 06-26-2012 at 10:10 PM. Reason: forgot the attachment

  8. #8
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Converting a Single Column to a Row with Commas?

    Hi,

    I assumed that you wanted a single cell that contained the concatenation of all the numbers. So after copying the formula in B2 down to the last cell, say B50, copy the cell and then from the menu select Paste Special Values. This will convert the formula in B50 to a text value.

    If you want to convert all the cells in column B just copy B1:B50 and again use Paste Special Values to paste back to B1.

  9. #9
    Registered User
    Join Date
    06-26-2012
    Location
    tx
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Converting a Single Column to a Row with Commas?

    Quote Originally Posted by Richard Buttrey View Post
    Hi,

    I assumed that you wanted a single cell that contained the concatenation of all the numbers. So after copying the formula in B2 down to the last cell, say B50, copy the cell and then from the menu select Paste Special Values. This will convert the formula in B50 to a text value.

    If you want to convert all the cells in column B just copy B1:B50 and again use Paste Special Values to paste back to B1.
    Richard,
    Thank you!! Yes, I want the single cell to go horizontal instead of vertical.

    1. Column B1 I typed: =A1

    2. Column B2 I typed: =B1&","&A2

    3. I dragged (copied) down to cell B9. Column B now looks like this:
    123
    123,45
    123,45,234
    123,45,234,789
    123,45,234,789,102
    123,45,234,789,102,145
    123,45,234,789,102,145,78965
    123,45,234,789,102,145,78965,12365
    123,45,234,789,102,145,78965,12365,12345

    4. Copied B9 and pasted as "Special Values" back to B1. Column B1 now looks like this:
    123,45,234,789,102,145,78965,12365,12345,45,234,789,102,145,78965,12365,12345

    My last question would be this: When I pasted back, it lost the formula, so if I added additional cells, it won't auto calculate. Would I just run the formula again? Is there a way to make this a default general function or action (not sure what to call it) so that I could apply it to any spreadsheet that I'm working in?

  10. #10
    Registered User
    Join Date
    06-26-2012
    Location
    tx
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Converting a Single Column to a Row with Commas?

    abousetta,

    Thank you so much! How would I apply this to my spreadsheets whenever I want to use it? I'm sorry for all of the questions, but this is new to me.

  11. #11
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Converting a Single Column to a Row with Commas?

    Well if the other sheets always have the same cell relationships you could just keep the B1 & B2 formula somewhere and then just copy and paste them to the ranges you're interested in.

    You lost the formula because of the Paste Special Values action. If you don't want to lose them just copy B9 and Paste Values to a cell other than B9 in this example, say C9.

  12. #12
    Registered User
    Join Date
    06-26-2012
    Location
    tx
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Converting a Single Column to a Row with Commas?

    Quote Originally Posted by Richard Buttrey View Post
    Well if the other sheets always have the same cell relationships you could just keep the B1 & B2 formula somewhere and then just copy and paste them to the ranges you're interested in.

    You lost the formula because of the Paste Special Values action. If you don't want to lose them just copy B9 and Paste Values to a cell other than B9 in this example, say C9.
    Duh, that makes sense too. Thanks again so much for humoring my basic questions. Is there a particular forum folder or website that I can go to to learn the basics of macros/VBS?

  13. #13
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Converting a Single Column to a Row with Commas?

    @moneal75 just add the code to a regular module like in the example I uploaded. This will provide you with a user-defined function that you can call in the worksheet.

    In any cell, write the formula:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    and put your actual range and type of delimter.

    So something like:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Hope this helps.

    abousetta

  14. #14
    Registered User
    Join Date
    06-26-2012
    Location
    tx
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Converting a Single Column to a Row with Commas?

    Great. Thank you!! So if I'm in the workbook, I click Ctr & F11, select "View/Macros/Record Macros"?

  15. #15
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Converting a Single Column to a Row with Commas?

    You can either show the developer tab on the ribbon or use Alt + F11 to jump into the vba window. Then insert --> module --> paste the code --> close the vba window.
    Last edited by abousetta; 06-27-2012 at 01:56 PM. Reason: Alt not Ctrl

  16. #16
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Converting a Single Column to a Row with Commas?

    Hi,

    If you are satisfied with the responses then please mark the thread as Solved.

  17. #17
    Registered User
    Join Date
    06-26-2012
    Location
    tx
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Converting a Single Column to a Row with Commas?

    Thank you so much for your patience in explaining that to me. I have a lot of learning to do!

  18. #18
    Registered User
    Join Date
    02-04-2014
    Location
    Queens
    MS-Off Ver
    Excel 2013
    Posts
    1

    Re: Converting a Single Column to a Row with Commas?

    Thanks a lot for your explanation!

+ 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