Converting wrapped text to normal using vba

I need a vba code to convert wrapped text to normal text. Its pain copying to notepad n pasting back. Thanks in advance.

Sub unwrap()
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    Dim str As String

    For Each char In ActiveSheet.UsedRange

        str = char.Value

        If Trim(Application.Clean(str)) <> str Then
            str = Trim(Application.Clean(str))
            char.Value = str
        End If

    Next

    Application.ScreenUpdating = True
    Application.Calculation = xlCalculationAutomatic

End Sub

Answers


Shooting in the Dark

Is this what you are trying?

Sub Sample()
    Dim ws As Worksheet
    Dim nCalc As Long

    On Error GoTo Whoa

    Application.ScreenUpdating = False
    nCalc = Application.Calculation
    Application.Calculation = xlCalculationManual

    '~~> Replace this with the actual sheet name
    Set ws = ThisWorkbook.Sheets("Sheet1")

    With ws
        .Cells.Replace What:=Chr(160), _
        Replacement:="", _
        LookAt:=xlPart, _
        SearchOrder:=xlByRows, _
        MatchCase:=False
    End With

LetsContinue:
    Application.ScreenUpdating = True
    Application.Calculation = nCalc

    Exit Sub
Whoa:
    MsgBox Err.Description
End Sub

Need Your Help

how to implement widget switches?

android switch-statement

I am looking for widget Switch. Not switch statement or switch activity etc.

garbled items in a horizontal list with css

css layout list

I have made a page in which i m using a list to display the items horizontally