2011-11-02 49 views
0

試圖在轉換爲製表符分隔的csv時,嘗試替換excel放入單元格中的句子之間的換行符。 嘗試了各種不同的方法chr(10)chr(13)vbcrlfvblf\n經典ASP刪除Excel換行符

這是一個大問題,因爲它是造成我的數組打破。

代碼:

response.write replace(replace(sLine,vbtab,""),CHR(),"|||") 

基本上試着用不同的方法負載替換。

+1

我們需要查看年代碼。 –

+0

'response.write replace(替換(sLine,vbtab,「」),CHR(),「|||」)' 基本上試過用不同的方法加載替換 – Scrappy

+0

你的代碼是否真的試圖調用CHR論據? – Martha

回答

0

這將刪除之前,之後和之間的所有換行符。選擇您的細胞或細胞範圍,然後運行marco。如果您正在尋找替換之前和之後,但在行之間只留下一個換行符,但沒有空行。我有一個可以做到的。

Sub RemoveLineBreaks() 
    Application.ScreenUpdating = False 
    Dim rngCell As Range 
    Dim strOldVal As String 
    Dim strNewVal As String 

    For Each rngCell In Selection 
     If rngCell.HasFormula = False Then 
      strOldVal = rngCell.Value 
      strNewVal = strOldVal 
      Debug.Print rngCel.Address 

      Do 

      strNewVal = Replace(strNewVal, vbLf, " ") 

      If strNewVal = strOldVal Then Exit Do 
       strOldVal = strNewVal 
      Loop 

      If rngCell.Value <> strNewVal Then 
       rngCell = strNewVal 
      End If 
     End If 
     rngCell.Value = Application.Trim(rngCell.Value) 
    Next rngCell 
    Application.ScreenUpdating = True 
End Sub