Find and Replace Carriage Return in Excel

rexwrx

New Member
Joined
Aug 29, 2006
Messages
16
Hi all,

I need to find all <CR> character (carriage return) because when I export a table from Access to Excel, the data contains "[]" that are carriage returns.

so i need to find these characters and replace with null

can i do this with vba?

many thanks :eek:
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

acw

MrExcel MVP
Joined
Feb 13, 2004
Messages
4,814
Hi

This should cover a CR, LF and CRLF.

Code:
Sub bbb()
  Cells.Replace what:=vbCr, replacement:=""
  Cells.Replace what:=vbLf, replacement:=""
  Cells.Replace what:=vbCrLf, replacement:=""
End Sub


Tony
 

rexwrx

New Member
Joined
Aug 29, 2006
Messages
16
cool thanks for that.

this one works better with the entire sheet.

Sub ChgInfo()
Dim Sht As Worksheet
For Each Sht In Worksheets
Sht.Cells.Replace What:="old stuff", _
Replacement:="new stuff", LookAt:=xlPart, MatchCase:=False
Next
End Sub
 

Forum statistics

Threads
1,136,269
Messages
5,674,741
Members
419,525
Latest member
helensesc

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top