'没有日期
Option Explicit
Sub test()
Dim i, j, k, pos, n, t, arr
pos = Split("3-2 4-3 5-4 6-5 7-6 8-7 10-8 11-9 12-10 14-11 15-12 16-13")
With Sheets("源数据")
arr = .Range("a2:m" & .Cells(Rows.Count, "a").End(xlUp).Row + 1)
End With
ReDim brr(1 To Rows.Count, 1 To 16)
For i = 1 To UBound(arr, 1) - 1
If arr(i, 2) = "来源名称" Then
For j = i + 1 To UBound(arr, 1) - 1
n = n + 1
brr(n, 2) = arr(i - 3, 3): brr(n, 9) = arr(i - 2, 3): brr(n, 13) = arr(i - 1, 3)
For k = 0 To UBound(pos)
t = Split(pos(k), "-"): brr(n, Val(t(0))) = arr(j, Val(t(1)))
Next
If Len(arr(j + 1, 1)) = 0 Then i = j: Exit For
Next
End If
Next
With Sheets("格式整理").[a2]
.Resize(Rows.Count - 1, UBound(arr, 2)).ClearContents
.Resize(n, UBound(brr, 2)) = brr
End With
End Sub |