You can transpose data in Excel using the Paste Special > Transpose feature, then use the TEXTJOIN function to add commas between the new horizontal list. This converts a vertical column of data into a comma-separated string while keeping the cells aligned for easy copying into other applications.
What You'll Need
- A computer with Microsoft Excel installed (Excel 2013 or later is recommended for the TEXTJOIN function).
- A dataset arranged in a single column (e.g., names, items, or codes) that you want to flip horizontally.
- A destination cell where the comma-separated text will appear.
Step-by-Step
- Select the column of data you wish to transpose. Click the top cell of the column and drag your mouse down to the last row you want to include. Ensure you do not include any empty cells at the bottom of the selection, or they will be included in the comma-separated list.
- Copy the selected cells. You can do this by right-clicking and selecting "Copy" from the context menu or by pressing Ctrl+C (Windows) or Cmd+C (Mac).
- Click on the cell where you want the transposed data to start. This should be the top-left cell of the area where you want the horizontal list to appear. It is crucial that this cell is empty and that there is enough horizontal space to the right for your data without overwriting other important information.
- Open the Paste Special dialog. Right-click on the selected cell and choose "Paste Special" from the menu.
- In the Paste Special dialog box, look for the section labeled "Operation" and select Transpose. This instructs Excel to flip the data horizontally, converting the column into a row.
- Click "OK" to apply the transpose. Your data is now arranged horizontally. Each item from the original column is now in its own cell, arranged left to right.
- Click on the cell immediately to the right of your transposed data. This is where you will type the formula that will combine all these cells into a single string separated by commas.
- Type the following formula into the cell:
=TEXTJOIN(",", TRUE, [range]). Replace[range]with the actual range of your transposed data. For example, if your data is in cellsB2:B10, the formula should be=TEXTJOIN(",", TRUE, B2:B10). - Press Enter to execute the formula. Excel will instantly combine all the values from the specified range into a single cell, placing a comma and a space between each item.
- Verify the result. Ensure that every item from your original list is present in the new comma-separated string and that there are no unexpected duplicates or missing items. The
TRUEargument in the TEXTJOIN function ensures that empty cells are ignored, which is useful if you had blank rows in your original dataset.
Common Mistakes
One of the most frequent errors users make is selecting the wrong range for the TEXTJOIN function. Because the data is now transposed horizontally, many users mistakenly select the original vertical range again, resulting in an error or incorrect output. Always double-check that the range argument in your formula matches the new horizontal location of your data.
Another common mistake is failing to account for extra spaces. If your original data had leading or trailing spaces (perhaps due to data entry errors), the comma-separated list will preserve those spaces. To clean this up, you can use the TRIM function by wrapping the range inside it, like this: =TEXTJOIN(",", TRUE, TRIM(B2:B10)). This removes any extra whitespace around the text values before joining them.
Tips
If you are working with a very large dataset, the TEXTJOIN function is significantly faster than using a series of ampersand concatenation formulas. Additionally, if you need to separate the items with a different character—such as a semicolon or a pipe—simply replace the comma inside the quotes with your desired character.
When using the Paste Special Transpose feature, be mindful of formatting. While the values are pasted correctly, the cell formatting (like currency symbols or date formats) is often lost in the process. You may need to manually re-apply number formatting to the new horizontal range for it to display correctly.
Troubleshooting
If the TEXTJOIN function returns a #NAME? error, it usually means that your version of Excel does not support this function. The TEXTJOIN function was introduced in Excel 2016 for Windows and Excel 2019 for Mac. If you are on an older version, you must use an array formula with the CONCATENATE or & operator, or use the PHONETIC function (though the latter is less robust).
If the result does not include all items, check if there are hidden rows or filters applied to the original dataset. Excel only transposes the visible cells, so any data in hidden rows will not appear in your new list. Unhide the rows or clear the filters to ensure you capture the full dataset.
If the comma-separated list looks cluttered or includes unnecessary spaces, check the source data for extra characters. The TEXTJOIN function treats every cell value exactly as it appears, so any invisible characters or accidental spaces in the original column will be copied over.
Frequently Asked Questions
Can I transpose a table with multiple columns?
Yes, you can transpose tables with multiple columns, but the result will be a single row containing all the cells from the table. If you need to maintain the structure of multiple rows, you must copy and paste each row individually or use a Power Query transformation.
Does the TEXTJOIN function work on dates?
The TEXTJOIN function works on dates, but the result will be the raw serial number of the date unless you wrap the values in the TEXT function. To display the date as a readable string, use =TEXTJOIN(",", TRUE, TEXT(B2:B10, "mm/dd/yyyy")).
How do I handle errors in the data?
By default, TEXTJOIN will include error messages in the final list. To ignore errors and only join valid text, you can use the IFERROR function to replace errors with an empty string, like this: =TEXTJOIN(",", TRUE, IFERROR(B2:B10, "")).
Is there a keyboard shortcut for Paste Special Transpose?
There is no universal keyboard shortcut for Paste Special Transpose, though some add-ins or custom macros can create one. The standard method requires using the right-click menu or the Home tab > Paste dropdown > Transpose button.
Can I use this method to create a CSV file?
Yes. Once you have your comma-separated text in a cell, you can copy it and paste it directly into a text editor like Notepad or TextEdit. From there, you can save the file with a .csv extension to create a comma-separated values file.