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---
"Francis Ang" wrote:
> 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.
|