ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clear a Carriage Return from a String Value (https://www.excelbanter.com/excel-programming/273620-re-clear-carriage-return-string-value.html)

RC-

Clear a Carriage Return from a String Value
 
Excellent!

Thank you, that works perfectly!

"Dan E" wrote in message
...
This will work on the selected range, clears the cr's lf's crlf's and

leaves nothing in their place

Sub ClearCRLF()
For Each Cell In Selection
temp = Cell.Text
For i = 1 To Len(temp)
a = Mid(temp, i, 1)
If a = vbCrLf Or a = vbCr Or a = vbLf Then
temp = Left(temp, i - 1) & Right(temp, Len(temp) - i - 1)
End If
Next
Cell.Value = temp
Next
End Sub

Dan E

"RC-" wrote in message

...
Hi All,

I have a string in a cell that has a Carriage Return in it. I'm

trying
to perform a Vertical Lookup and it's not working because of the CR.

How
can I programmatically remove the CR from the String(s)?



Any help would be great!

RC-



BTW - I already tried the Trim function that did not work.








All times are GMT +1. The time now is 02:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com