Removing carriage returns from delimited file

KGee

Well-known Member
Joined
Nov 26, 2008
Messages
537
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a comma delimited which uses double-quotes as the text qualifier. I import this file into another program and perform some analysis before generating a report in Excel. The problem I've run into is one of the fields in the original file can have carriage returns/line feeds within the field. I need to remove those before I can analyze the file as it's causing problems during my import.

I've set the variable "replaceVal" to the "Chr(13)Chr(10)" which I need to replace and that works but I need to make a few changes:
I'm losing my "" around each field, is there any way around this? I need to resave the file in delimited format but the quotes around each field are not being retained.
Can this be rewritten to replace only when the "replaceVal" is found within a string of ""?

Code:
Worksheets("Main").Columns("A:G").Replace _
What:=replaceVal, Replacement:="", _
SearchOrder:=xlByColumns, MatchCase:=True
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
I am not sure that I understand the problem that you are having with the double-quotes but, in case it helps, you can remove the Chr(13)Chr(10) using the Excel function CLEAN.
 
Upvote 0

Forum statistics

Threads
1,214,386
Messages
6,119,217
Members
448,876
Latest member
Solitario

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