Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to convert carriage return to comma in Excel?

Maybe you have a lot of cells which have the values are separated by carriage returns, and now you need to find all the carriage returns and replace them with commas or other characters as following screenshot shown. How could you convert all the carriage returns to commas or other characters in a worksheet quickly and easily?

doc-convert-carriage-to-comma-1

Convert carriage returns to commas with formula

Convert carriage returns to commas with Find and Replace function

Convert carriage returns to commas with VBA code


arrow blue right bubble Convert carriage returns to commas with formula


The following simple formula can help you to replace the carriage returns to commas or other characters with ease.

1. Please type this formula into a blank cell besides your data: =SUBSTITUTE(A1,CHAR(10),",") (A1 indicates the cell which you want to replace the carriage return, and the comma between the quotation marks is the character that you want to use, you can change them as your need.), see screenshot:

doc-convert-carriage-to-comma-1

2. Then drag the fill handle over to the range that you want to apply this formula, and you will get the following result that the carriage returns are replaced by the commas.

doc-convert-carriage-to-comma-1


arrow blue right bubble Convert carriage returns to commas with Find and Replace function

The Find and Replace function also can help you to convert the carriage returns to commas at once. Please do as follows:

1. Select the data range that you want to convert the carriage returns.

2. Click Home > Find & Select > Replace or use the shortcuts Ctrl + H keys to open the Find and Replace dialog box, see screenshot:

doc-convert-carriage-to-comma-1

3. In the Find and Replace dialog box, in the Find what field, please press Ctrl + J keys, and in the Replace with field, type the characters that you want, in this case, I will type the comma(,), see screenshot:

doc-convert-carriage-to-comma-1

4. Then click Replace All button, and a prompt box will pop out to remind you how many replacements has been made. See screenshot:

doc-convert-carriage-to-comma-1

5. And then click OK and close the Find and Replace dialog, all the carriage returns have been replaced with the commas.

doc-convert-carriage-to-comma-1


arrow blue right bubble Convert carriage returns to commas with VBA code

If you are interested in VBA code, I can introduce you a code to solve this job.

1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module Window.

VBA code: Convert carriage returns to commas

Sub ReplaceCarriage()
'Update 20141023
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
For Each Rng In WorkRng
Rng.Value = Replace(Rng.Value, Chr(10), ",")
Next
End Sub

3. Then press F5 key to run this code, and a prompt box pops out to remind you select the data range that you want to use. See screenshot:

doc-convert-carriage-to-comma-1

4. Then click OK, and the carriage returns have been converted to commas immediately.

Note:

In the above code, you can change the comma "," within the Rng.Value = Replace(Rng.Value, Chr(10), ",") script to any other characters as you like.


Related articles:

How to quickly remove line breaks in Excel?

How to split cells into multiple columns or rows by carriage return?


Recommended Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 71%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 82% Excel problems.

  •  Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  •  Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  •  Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  •  Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  •  No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  •  Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  •  60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  •  Change the way you work now, and give you a better life immediately!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.