I want to get rid of all the carriage returns in my cell. How do I do this?
I want to get rid of all the carriage returns in my cell. How do I do this?
Sub RemoveLineBreaks()
Application.ScreenUpdating = False
Dim rngCel As Range
Dim strOldVal As String
Dim strNewVal As String
For Each rngCel In Selection
If rngCel.HasFormula = False Then
strOldVal = rngCel.Value
strNewVal = strOldVal
Debug.Print rngCel.Address
Do
strNewVal = Replace(strNewVal, vbLf, " ")
If strNewVal = strOldVal Then Exit Do
strOldVal = strNewVal
Loop
If rngCel.Value <> strNewVal Then
rngCel = strNewVal
End If
End If
rngCel.Value = Application.Trim(rngCel.Value)
Next rngCel
Application.ScreenUpdating = True
End Sub