Auf der Basis deines PgmCodes habe ich dir, ...
18.11.2015 02:49:13
Luc:-?
…Emre,
mal ein Bsp dafür geschrieben, wie ich mir das vorstelle. Die irrelevanten Teile msst du dann natürlich durch deine Organisation ersetzen:
Sub TrennTest()
Const txIntro$ = "Werte:", txHTrenn$ = " , ", txVTrenn$ = vbCrLf
Dim lngPos As Long, strAnfang$, strText$, vntArrayWerte
strText = ActiveWindow.RangeSelection
Do While strText Like "*" & txHTrenn & "#*" 'primär lngPos=0
lngPos = InStr(lngPos + 1, strText, txHTrenn)
If CBool(lngPos) Then
If IsNumeric(Mid(strText, lngPos + 4, 1)) Then _
strText = Left(strText, lngPos - 1) & Chr(0) & _
Mid(strText, lngPos + 3)
Else: Exit Do
End If
Loop
vntArrayWerte = Split(strText, Chr(0))
lngPos = InStr(vntArrayWerte(0), txIntro)
If CBool(lngPos) Then
strAnfang = Mid(vntArrayWerte(0), 1, lngPos - 1 + Len(txIntro))
vntArrayWerte(0) = LTrim(Mid(vntArrayWerte(0), lngPos + Len(txIntro)))
End If
strText = vntArrayWerte(UBound(vntArrayWerte))
ReDim Preserve vntArrayWerte(UBound(vntArrayWerte) - 1)
For lngPos = 0 To UBound(vntArrayWerte) 'nur als Test
vntArrayWerte(lngPos) = _
Replace(vntArrayWerte(lngPos), txHTrenn, LTrim(txHTrenn))
If MsgBox(vntArrayWerte(lngPos), vbInformation + vbOKCancel, _
strAnfang & " horText " & lngPos + 1) = vbCancel Then Exit For
Next lngPos
vntArrayWerte = Empty: vntArrayWerte = Split(strText, txVTrenn)
For lngPos = 0 To UBound(vntArrayWerte) 'nur als Test
vntArrayWerte(lngPos) = _
Replace(vntArrayWerte(lngPos), txHTrenn, LTrim(txHTrenn))
If MsgBox(vntArrayWerte(lngPos), vbInformation + vbOKCancel, _
strAnfang & " verText " & lngPos + 1) = vbCancel Then Exit For
Next lngPos
End Sub
Mit folgd TestText hat das wie erwartet fktioniert:
Alfa-Werte: 12345: BspWert0 , 4567: BspWert1 , 25999: BspWert2 , 1188: Bsp , Wert3 , 33123: BspWert4 , 1234: BspWert5 , 56789: BspWert6 , 999: BspWert7 , 8888: Bsp , Wert8 , 77777: BspWert9 , 9901: BspWert10
9902: BspWert11
9903: BspWert12
9904: BspWert13
9905: BspWert14
Morrn, Luc :-?