2011-11-02 52 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