Sub test()
Dim a, i As Long, n As Long, myDate
With Sheets("input")
a = .Range("a1", .Range("a" & .Rows.Count).End(xlUp)).Value
End With
With CreateObject("VBScript.RegExp")
.Pattern = "^([^\|]+)" & Application.Rept(" *\| *(\-?\d+(\.\d+)?)", 9) & "$"
For i = 1 To UBound(a, 1)
If IsDate(a(i, 1)) Then myDate = a(i, 1)
If IsDate(myDate) Then
If .test(a(i, 1)) Then
n = n + 1
a(n, 1) = .Replace(a(i, 1), "$1,-," & _
Format$(myDate, "ddmmyyyy") & ",$2,$4,$6,$8,$16")
End If
End If
Next
End With
Sheets("output").Cells(1).Resize(n).Value = a
End Sub
Bookmarks