VBA to replace in-cell CR/LF characters with spaces?

itm

New Member
Joined
Mar 20, 2010
Messages
9
I'm a novice with Excel macros, but am looking for a code sample which will examine a column of cells in a CSV file and replace all in-cell CR/LF characters with space characters.

The file in question is created by exporting values from database. One of the exported columns frequently contains Hex 0d0a characters within the text, and these need to be replaced with spaces.

TIA for any guidance
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Further to what pman has mentioned.

Select the column and run this statement from VBE Immediate window. You may put this line in a macro.
Code:
[FONT="Consolas"][SIZE="2"][COLOR="Navy"]Selection.Replace What:=Chr(13), Replacement:=" "[/COLOR][/SIZE][/FONT]
 
Upvote 0

Forum statistics

Threads
1,203,514
Messages
6,055,838
Members
444,828
Latest member
StaffordStag

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
Back
Top