无法通过换行符拆分单元格内容

我的VBA脚本应该是通过换行将一个单元格中的内容分割成几行,它适用于某些单元格,在一个单元格中的date如下所示:

a01gestmstrs2a 10.67.15.17 a01gestmdb2a 10.67.15.19 a01gstdbldnim1a a01rstdbldnim1a a01gestmstrs2b (10.67.15.46) a01restmdb2a (10.67.15.48) a01gestmstrs2z 10.67.15.20 a01gestmdb2b (10.67.15.47) a01restmstrs2a (10.67.15.49) 

然而,它不能像上面提供的样本分裂,我不明白为什么。 我的代码:

 Sub SplitMultipleHostnames() Dim tmpArr As Variant Dim s As String Application.ScreenUpdating = False Application.Calculation = xlCalculationManual For Each cell In Range("D2", Range("D3").End(xlDown)) For Each c In ActiveSheet.UsedRange s = c.Value If Trim(Application.Clean(s)) <> s Then s = Trim(Application.Clean(s)) c.Value = s End If If cell.Value <> "" Then If InStr(1, cell, Chr(10)) <> 0 Then tmpArr = Split(cell, Chr(10)) cell.EntireRow.Copy cell.Offset(1, 0).Resize(UBound(tmpArr), 1).EntireRow.Insert xlShiftDown cell.Resize(UBound(tmpArr) + 1, 1) = Application.Transpose(tmpArr) End If Else cell.EntireRow.Delete cell.Row = cell.Row - 1 End If Next Next Application.ScreenUpdating = True Application.Calculation = xlCalculationAutomatic Application.CutCopyMode = False End Sub 

他们实际上不是Char(10)他们是空格。 我改变了代码“”,它工作正常

  If cell.Value <> "" Then If InStr(1, cell, " ") <> 0 Then tmpArr = Split(cell, " ") 

使用Trim()Clean()的循环将从工作表中删除所有的ASCII 10和13。

没有什么可以拆分()