Assuming every line has complete pair of location# and seat# in order.
Sub test()
Dim fn As String, txt As String, x, y, z, i As Long, ii As Long, temp
fn = ThisWorkbook.Path & "\test.txt" '<- file path for .txt
txt = CreateObject("Scripting.FileSystemObject").OpenTextFile(fn).ReadAll
x = Split(txt, vbCrLf)
For i = 0 To UBound(x)
If x(i) Like "*,*" Then
y = Split(x(i), ",", 2)
If y(1) Like "*,*,*" Then
z = Split(y(1), ",")
For ii = 0 To UBound(z) \ 2
temp = temp & vbCrLf & y(0) & "," & z(ii) & _
"," & z(ii + UBound(z) \ 2 + 1)
Next
End If
Else
temp = temp & vbCrLf & x(i)
End If
Next
Open Replace(fn, ".txt", "-Updated.txt") For Output As #1
Print #1, Mid$(temp, 3)
Close #1
End Sub
Bookmarks