Where does the data originate? Can you change the format? Always easier to make changes as close to source as possible.
Here is a routine that may help you get started:
Code:
Option Compare Database
Option Explicit
'Name Location Name_Link Location_Link Final_Location
'C50 2398::3276::3916 GA-4-2 58::52::24 558::352::324::70
'Name and Name_Link are related
'Location and Location_Link are relative values realted to Name
'Final_Location applies to Name,Name_link only
Type mRec
mName As String
mLocation As Variant
mName_link As String
mLocation_Link As Variant
mFinal_Location As Variant
End Type
'---------------------------------------------------------------------------------------
' Procedure : concX
' Author : mellon
' Date : 12/07/2016
' Purpose :query to split concatenated string into separate parts
' https://www.accessforums.net/showthread.php?t=60751&p=324641#post324641
'---------------------------------------------------------------------------------------
'
Sub concX()
Dim Q As mRec
Dim i As Integer, j As Integer, k As Integer, m As Integer
Dim x As String
Dim xarray As Variant
Dim LocArray As Variant
Dim LocLink As Variant
Dim FinalLoc As Variant
On Error GoTo concX_Error
10 x = "C50 2398::3276::3916 GA-4-2 58::52::24 558::352::324::70"
20 xarray = Split(x, " ")
30 For i = LBound(xarray) To UBound(xarray)
'Debug.Print xarray(i)
40 Select Case i
Case 0
50 Q.mName = xarray(i)
60 Debug.Print Q.mName
70 Case 1
80 Q.mLocation = xarray(i)
90 LocArray = Split(xarray(i), "::")
100 For j = LBound(LocArray) To UBound(LocArray)
110 Debug.Print " " & LocArray(j)
120 Next j
130 Case 2
140 Q.mName_link = xarray(i)
150 Debug.Print " " & Q.mName_link
160 Case 3
170 Q.mLocation_Link = xarray(i)
180 LocLink = Split(xarray(i), "::")
190 For k = LBound(LocLink) To UBound(LocLink)
200 Debug.Print " " & LocLink(k)
210 Next k
220 Case 4
230 Q.mFinal_Location = xarray(i)
240 FinalLoc = Split(xarray(i), "::")
250 For m = LBound(FinalLoc) To UBound(FinalLoc) - 1
'Debug.Print " -- " & FinalLoc(m)
260 Debug.Print Q.mName & " " & LocArray(m) & " " & Q.mName_link & " " & LocLink(m) & " " & FinalLoc(m)
270 Next m
280 Debug.Print Q.mName & " " & Q.mName_link & " " & FinalLoc(UBound(FinalLoc))
290 Case Else
300 MsgBox "an error hs occurred in parsing the incoming string"
310 End Select
320 Next i
On Error GoTo 0
Exit Sub
concX_Error:
MsgBox "Error " & err.number & " in line " & Erl & " (" & err.Description & ") in procedure concX of Module Module5"
End Sub
Debug output
Code:
C50
2398
3276
3916
GA-4-2
58
52
24
C50 2398 GA-4-2 58 558
C50 3276 GA-4-2 52 352
C50 3916 GA-4-2 24 324
C50 GA-4-2 70