Hallo,
ja im Prinzip kommst Du da so ran, könnte man auch per RegEx kürzer machen, oder auch in eine Function übertragen...
Option Explicit
Public Sub test()
Const SEARCH_STRING1 As String = "| PUN-6X1-BL | Art Nr.: 159664 | VPE= 1m | Preis= 1,20€"
Const SEARCH_STRING2 As String = "*VPE*"
Const SEARCH_STRING3 As String = "*Preis*"
Const SEARCH_CHARS1 As String = "= "
Const SEARCH_CHARS2 As String = "m"
Const SEARCH_CHARS3 As String = "€"
Dim astrArray() As String
Dim ialngIndex As Long, alngPos(1 To 4) As Long
Dim strText As String, strSearch1 As String, strSearch2 As String
strSearch1 = Mid$(String:=SEARCH_STRING2, Start:=2, Length:=Len(SEARCH_STRING2) - 2)
strSearch2 = Mid$(String:=SEARCH_STRING3, Start:=2, Length:=Len(SEARCH_STRING3) - 2)
astrArray = Split(Expression:=SEARCH_STRING1, Delimiter:="|")
For ialngIndex = 0 To UBound(astrArray)
If astrArray(ialngIndex) Like SEARCH_STRING2 Or astrArray(ialngIndex) Like SEARCH_STRING3 Then
alngPos(1) = InStr(1, astrArray(ialngIndex), SEARCH_CHARS1)
alngPos(2) = InStr(1, astrArray(ialngIndex), SEARCH_CHARS2)
alngPos(3) = InStr(1, astrArray(ialngIndex), SEARCH_CHARS3)
alngPos(4) = IIf(Right$(String:=astrArray(ialngIndex), Length:=1) = " ", 2, 1)
strText = strText & IIf(astrArray(ialngIndex) Like SEARCH_STRING2, strSearch1, strSearch2) & " : " & _
Mid$(String:=astrArray(ialngIndex), _
Start:=alngPos(1) + 2, Length:=Len(astrArray(ialngIndex)) - alngPos(1) - 1 - alngPos(4)) & vbCr
End If
Next
Call MsgBox(strText, vbExclamation)
End Sub
Gruß,
|