

All the SUBSTITUTE() function does is replace a character or characters in a text with another character. So in a a cell next to the cell with all your text, you can write the following formula to replace all the line breaks with a comma: =SUBSTITUTE(B2,CHAR(10),",") In Excel, you can use the CHAR() function to represent different ASCII codes so we can do CHAR(10) to represent a line break.


#HOW TO HAVE TEXT FILE PASTE INTO EXCEL COLUMNS CODE#
The ASCII character code for a new line break is 10 for PCs and 13 for Macs. The key with using the SUBSTITUTE() function is we want to replace each new line with a comma. Notice the commas after every value? Once the text in the cell looks like this, then we are ready to use the Text-to-Columns button to split the text up by the commas that separates each value. We basically want the text in this cell to look like this: It doesn’t seem intuitive, but what we need to do is format the cell with multiple lines of text so that it’s easy for the Text-to-Columns operation to work. The simple answer is using the function SUBSTITUTE() . Why is it so hard? Convert Text to Columns For Cell With Multiple Lines With SUBSTITUTE() How do we solve this?Ĭonvert text to columns when the cell has multiple lines of text. The problem is, there is no delimiter! You could add a comma after each value but that would take forever if you had a cell with say 50 lines of text. In this case, it looks like this was a database dump and all the text is put into one cell and our job is to put each value into a new column. This is all in one cell and each text is separated by a new line. What happens when you have multiple text in a cell entered in as new lines like this? You have text in the format “Last Name, First Name” and you want to split this into two columns with one column being the First Name and the next column being the Last Name. This is probably one of the most common use cases of Text-to-Columns I’ve seen. Usually in one cell, you’ll have a long line of text that is separated by commas, semicolons, or some other delimiter and all you’re trying to do is get each value into its own column. You’ve probably had to convert text to columns before in Excel. ascii, multiple lines, new line breaks, substitute, text to columns.Home / Convert Text to Columns With Multiple Lines Convert Text to Columns With Multiple Lines
