参与一下。。。
- Sub ykcbf() '//2024.12.18
- With Sheets("原料")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 6)
- End With
- ReDim brr(1 To 10000, 1 To 6)
- For i = 2 To UBound(arr)
- If InStr(arr(i, 1), "供应商") Then
- m = m + 1
- For j = 1 To 4
- brr(m, j) = arr(i, j)
- Next
- brr(m, 5) = "日期"
- brr(m, 6) = "数量"
- rr = i
- Else
- For j = 5 To UBound(arr, 2)
- m = m + 1
- For x = 1 To 4
- brr(m, x) = arr(i, x)
- Next
- brr(m, 5) = arr(rr, j)
- brr(m, 6) = arr(i, j)
- Next
- End If
- Next
- With Sheets("原料转竖计划")
- .UsedRange.ClearContents
- .Columns(5).NumberFormatLocal = "m月d日"
- .[a1].Resize(m, 6) = brr
- End With
- MsgBox "OK!"
- End Sub
复制代码
|