Sub test()
Dim a, i As Long, ii As Long
With Range("a2", Range("a" & Rows.Count).End(xlUp)).Resize(, 4)
.Offset(1, 1).ClearContents: a = .Value
With CreateObject("VBScript.RegExp")
.Pattern = "(.*) Origin[:.] ([A-Z]{3}).* (\d+) *$"
For i = 2 To UBound(a, 1)
If .test(a(i, 1)) Then
For ii = 2 To 4
a(i, ii) = .Replace(a(i, 1), "$" & ii - 1)
Next
End If
Next
End With
.Value = a
End With
End Sub
Try
Code:Sub test() Dim a, i As Long, ii As Long With Range("a2", Range("a" & Rows.Count).End(xlUp)).Resize(, 4) .Offset(1, 1).ClearContents: a = .Value With CreateObject("VBScript.RegExp") .Pattern = "(.*) Origin[:.] ([A-Z]{3}).* (\d+) *$" For i = 2 To UBound(a, 1) If .test(a(i, 1)) Then For ii = 2 To 4 a(i, ii) = .Replace(a(i, 1), "$" & ii - 1) Next End If Next End With .Value = a End With End Sub
You have specified you need VBA solution but following formula also work for the data posted in the last post.
In B3:
=LEFT(A3,SEARCH(" Origin",A3)-1)
In C3:
=LEFT(TRIM(MID(A3,SEARCH(" Origin",A3)+8,99)),3)
In D3:
=TRIM(RIGHT(SUBSTITUTE(A3," ",REPT(" ",99)),99))