How to replace alt-enter with space/comma in Excel?
For example, there are some cells with carriage returns as below screenshot shown. Now you want to replace these alt-enter characters with space or comma in Excel, how could you deal with it? Actually, both Find and Replace feature and VBA can help you solve the problem.
- Replace alt-enter with space/comma by Find and Replace feature
- Replace alt-enter with space/comma by VBA
You can easily replace all-enter characters with space or comma by the Find and Replace feature in Excel. Please do as follows:
1. Select the cells you will replace the alt-enter characters, and press Ctrl + H keys to open the Find and Replace dialog box.
2. In the Find and Replace dialog box, under the Replace tab, please:
(1) In the Find What box press Ctrl + J keys to enter alt-enter character;
(2) In the Replace with box type space or comma as you need;
(3) Click the Replace All button. See screenshot:
3. Click the OK button in the popping out Microsoft Excel dialog box. And then close the Find and Replace dialog box.
Now you will see all alt-enter characters are replaced with your specified character, such as a comma. See screenshot:
If you are familiar with VBA, you can also replace the alt-enter characters with space, comma, or any other character as you need with VBA in Excel.
1. Press Alt + F11 keys to open the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and then paste below VBA code into the new module window.
VBA: Replace alt-enter with space/comma in Excel
Sub ReplaceLineBreak() Dim xRg As Range On Error Resume Next Set xRg = Application.InputBox("Select Cells:", "KuTools for Excel", Selection.Address, , , , , 8) If xRg Is Nothing Then Exit Sub xRg.WrapText = False xRg.Replace Chr(10), "Your text here", xlPart, xlByColumns End Sub
Note: Before running the VBA, please find the code xRg.Replace Chr(10), "Your text here", xlPart, xlByColumns, and replace Your text here with space, comma, or other character as you need.
3. Press F5 key or click the Run button to run this VBA.
4. In the popping out KuTools for Excel dialog box, please select the cells you will replace the alt-enter characters, and click the OK button. See screenshot:
Now you will see all alt-enter characters are replaced with you specified character, such as comma. See screenshot:
Best Office Productivity Tools
Supports Office/Excel 2007-2021 and 365 | Available in 44 Languages | Easy to Uninstall Completely
Kutools for Excel Boasts Over 300 Features, Ensuring That What You Need Is Just A Click Away...
Supercharge Your Excel Skills: Experience Efficiency Like Never Before with Kutools for Excel (Full-Featured 30-Day Free Trial)
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day! (Full-Featured 30-Day Free Trial)