Вот один подход, использующий оператор Like
:
Sub test()
Dim var1, var2, var3, var4, var5, var6 'as variant
Dim string1 As String, s As String
Dim items As Variant
Dim i As Long
string1 = "L100;G50;XYZ12,5;E11/11/2018;NF1;Osomefreetext"
items = Split(string1, ";")
For i = 0 To UBound(items)
s = items(i)
If s Like "L*" Then
var1 = Mid(s, 2)
ElseIf s Like "G*" Then
var2 = Mid(s, 2)
ElseIf s Like "XYZ*" Then
var3 = Mid(s, 4)
ElseIf s Like "E*" Then
var4 = Mid(s, 2)
ElseIf s Like "NF*" Then
var5 = Mid(s, 3)
ElseIf s Like "O*" Then
var6 = Mid(s, 2)
'Else error trapping code
End If
Next i
Debug.Print "Extracted " & Join(Array(var1, var2, var3, var4, var5, var6), ", ")
End Sub
Вывод:
Extracted 100, 50, 12,5, 11/11/2018, 1, somefreetext