Excel

Remove Carriage / Paragraph Returns from Within Cells

Ease of Use

Easy

Version tested with

2000, 2002, 2003 

Submitted by:

Anne Troy

Description:

Removes carriage returns placed by using Alt+Enter in the entire Activesheet. 

Discussion:

This macro will remove returns created by hitting Alt+Enter within cells in Excel, and replace them with a space. 

Code:

instructions for use

			

Option Explicit Sub RemoveRtns() Dim cel As Range For Each cel In ActiveSheet.UsedRange cel = Replace(cel, Chr(10), " ") Next End Sub

How to use:

  1. Copy above code.
  2. In Excel press Alt + F11 to enter the VBE.
  3. Press Ctrl + R to show the Project Explorer.
  4. Right-click desired file on left (in bold).
  5. Choose Insert -> Module.
  6. Paste code into the right pane.
  7. Press Alt + Q to close the VBE.
  8. Save workbook before any other changes.
 

Test the code:

  1. Navigate to the worksheet on which you want to run the code, and hit Tools-->Macro, Macros, and double-click RemoveRtns.
 

Sample File:

RemoveRtns.zip 6.77KB 

Approved by mdmackillop


This entry has been viewed 216 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express