Carriage Return and Line Feed

  • Thread starter Thread starter Francis Ang
  • Start date Start date
F

Francis Ang

I am trying to remove the 'carriage return' or 'line feed' from a text file.
I tried using the RIGHT and MID commands but it is not working.

I have searched the community website for examples but could not find any.

Could someone please help me out.

Thank you.
 
Replace(strData,vbLF,"") for linefeed
Replace(strData,vbCrLF,"") for CRLF

If this post helps click Yes
 
You can try a few things...

Delete All Hard Returns:
Sub Remove_CR_LF()
With Selection
..Replace What:=Chr(39), Replacement:=Chr(32), _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
..Replace What:=Chr(146) & Chr(10), Replacement:=Chr(32), _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
..Replace What:=Chr(180), Replacement:=Chr(32), _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
End With
End Sub

Sub Remove_CR_LF()
With Selection
..Replace What:=Chr(160), Replacement:=Chr(32), _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
..Replace What:=Chr(13) & Chr(10), Replacement:=Chr(32), _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
..Replace What:=Chr(10), Replacement:=Chr(32), _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
End With
End Sub


I think those are ASCII Chr(13); yo may have other things in there too...
Backup your data before running any macros, just in case the results are
unintended...

HTH,
Ryan---
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top