2014-01-30 14 views
-3

我需要一個vba代碼來將封裝文本轉換爲普通文本。它的痛苦複製到記事本粘貼回來。 在此先感謝。使用vba將封裝文本轉換爲正常

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 
+1

[有趣的閱讀](http://meta.stackexchange.com/questions/156810/stack-overflow-question-checklist) –

+0

我對不起siddarth我問怎麼我被卡住了ňSRY我不能接受你的意見。是的,我不張貼沒有嘗試謝謝。 – Varshaan

+0

'是的,我沒有發佈沒有試試謝謝'你能告訴我們你有什麼試過?您是否閱讀了我在上次評論中提供的鏈接? –

回答

1

拍攝黑暗中的

這是你想什麼呢?

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 
+0

yeyyy它的工作感謝傢伙和遺憾的錯誤張貼。 spl謝謝@SiddharthRout它完美的工作:) – Varshaan