How to remove a CR and LF form txt file

fritserasmus

New Member
Joined
Aug 15, 2015
Messages
2
I have a file with 147693 lines.
I need to remove 6 pairs of CR and LF at the end of the first 6 lines,
then skip one (which is a legitimate CR, LF)
then continue to the following 6 pairs.

Any help ho to do that?
I understand I will have to write a macro to do this, but have no idea hoe to find and remove / go to next CR to remove.

I tried this in Notepad ++
It runs fine if I do 50 at a time when running a macro, but Notepad ++ gets confused if I try to do more than 500 at a time.
Ideally I would like to do it in Excel in one go.

I can provide the original file; truncated after say 1000 records and then the matching Microsoft Excel file that was successfully converted..If needed.

Any advice will be appreciated very much

Frits
 
i would be tempted to delete all the CR LF charaters and then use a For next loop to add back i.e

For n = 1 to LR step 6
next n
 
Upvote 0
i would be tempted to delete all the CR LF charaters and then use a For next loop to add back i.e

For n = 1 to LR step 6
next n

Wish I could attach the PDF I am able to export as well as the Excel sheet I need.
Nevertheless, would you mind to explain in a bit more detail how to delete the CR and LF to get the Excel file I need?

Kind Regards

Frits
 
Upvote 0
I had same sort of issue: need to replace spaces and dashes.

I have used this command:

dPLC = Replace(mPLC, " ", "")

With this command, I was able to remove spaces.
Might be a good idea to use replace command to replace CR LF characters
Best regards
 
Upvote 0

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