AW: mit VBA Text aufsplitten auf mehrere Zellen
01.10.2014 10:50:19
fcs
Hallo Franzi,
Daniels Vorschlag mit dem Leerzeichen als Trennzeichen funktioniert bei mir nicht 100%.
Günstiger ist es + und - durch = zu ersetzen, bevor man die Split-Funktion einsetzt.
Gruß
Franz
Sub TestSplit_2()
Dim strText As String, strSep As String
Dim Zeile As Long
On Error Resume Next
strSep = "=" 'oder anderes Zeichen, das in den Zellinhalten nicht vorkommt
For Zeile = 3 To 5
strText = Cells(Zeile, 1).Text
If strText "" Then
strText = Replace(strText, "=", strSep)
strText = Replace(strText, "+", strSep)
strText = Replace(strText, "-", strSep)
strText = Trim(strText)
Cells(Zeile, 2) = Trim(Split(strText, strSep)(0))
Cells(Zeile, 3) = Trim(Split(strText, strSep)(1))
Cells(Zeile, 4) = Trim(Split(strText, strSep)(2))
Cells(Zeile, 5) = Trim(Split(strText, strSep)(3))
End If
Next
End Sub