Ich bekomme Straßennamen übergeben in der Form
VierländerDamm78A
Weiß jemand, ob es eine Funktion zum Trennen dieser Daten gibt? Oder einen Lösungsansatz?
Danke
Michael
Option Explicit
Sub Trennen()
Dim A As Long, B As Long
B = 1
For A = 1 To Cells(Rows.Count, 1).End(xlUp).Row
Do While B <= Len(Cells(A, 1))
If InStr("1234567890", Mid(Cells(A, 1), B, 1)) > 0 Then
Cells(A, 2) = Left$(Cells(A, 1), B - 1)
Cells(A, 3) = Right$(Cells(A, 1), Len(Cells(A, 1)) - B + 1)
Exit Do
End If
B = B + 1
Loop
B = 1
Next A
End Sub
Gruß Tino
Sub Trennen()
Dim A As Long, B As Long
B = 1
For A = 1 To Cells(Rows.Count, 1).End(xlUp).Row
Do While IsNumeric(Mid(Cells(A, 1), Len(Cells(A, 1)) - B, 1))
B = B + 1
Loop
Cells(A, 2) = Left$(Cells(A, 1), Len(Cells(A, 1)) - B)
Cells(A, 3) = Right$(Cells(A, 1), B)
B = 1
Next A
End Sub
Gruß Tino
Public Sub TrennEs()
Dim lZeile As Long
Dim sZeichen As String
Dim iIndex As Integer
For lZeile = 1 To Cells(Rows.Count, 1).End(xlUp).Row
Range("B" & lZeile & ":C" & lZeile).ClearContents
Cells(lZeile, 1).Value = Trim(Cells(lZeile, 1).Value)
For iIndex = 1 To Len(Cells(lZeile, 1).Value)
sZeichen = Mid(Cells(lZeile, 1).Value, iIndex, 1)
If IsNumeric(sZeichen) Then
Cells(lZeile, 3).Value = Mid(Cells(lZeile, 1).Value, iIndex)
Exit For
Else
If sZeichen = UCase(sZeichen) And iIndex > 1 Then
Cells(lZeile, 2).Value = Cells(lZeile, 2).Value & " "
Cells(lZeile, 2).Value = Cells(lZeile, 2).Value & sZeichen
Else
Cells(lZeile, 2).Value = Cells(lZeile, 2).Value & sZeichen
End If
End If
Next iIndex
Next lZeile
End Sub
Sub test()
Cells(1, 1).Value = Splitten(Cells(1, 1).Value)
End Sub
Function Splitten(strText As String)
Dim i As Integer, strNeuer As String
strNeuer = Left$(strText, 1)
For i = 2 To Len(strText)
If UCase(Mid$(strText, i, 1)) = Mid$(strText, i, 1) Then
If Not IsNumeric(Right$(strNeuer, 1)) And Not IsNumeric(Mid$(strText, i - 1, 1)) Then
strNeuer = strNeuer & " "
End If
End If
strNeuer = strNeuer & Mid$(strText, i, 1)
Next
Splitten = strNeuer
End Function
Grüße Gerd
Die erweiterte Suchfunktion hilft dir, gezielt die besten Antworten zu finden
Suche nach den besten AntwortenEntdecke unsere meistgeklickten Beiträge in der Google Suche
Top 100 Threads jetzt ansehen