|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
参与一下。。。
- Sub ykcbf() '//2024.8.29
- Application.ScreenUpdating = False
- With Sheets("Sheet1")
- r = .Cells(Rows.Count, 1).End(3).Row
- c = .Cells(1, "XFD").End(1).Column
- c1 = .Rows(1).Find("订单数量", LookIn:=xlValues).Column
- arr = .[a1].Resize(r, c)
- ReDim brr(1 To 10000, 1 To c + 4)
- For i = 2 To UBound(arr)
- n = arr(i, c1) \ arr(i, c1 + 1)
- If n * arr(i, c1 + 1) = arr(i, c1) Then n = n Else n = n + 1
- For x = 1 To n
- m = m + 1
- brr(m, 1) = m
- For j = 1 To UBound(arr, 2)
- brr(m, j + 1) = arr(i, j)
- Next
- If x < n Then brr(m, c + 2) = arr(i, c1 + 1) Else brr(m, c + 2) = arr(i, c1) - (n - 1) * arr(i, c1 + 1)
- brr(m, c + 3) = x
- brr(m, c + 4) = n
- Next
- Next
- End With
- With Sheets("Sheet2")
- .UsedRange.Offset(1).Clear
- .[a2].Resize(m, c + 4) = brr
- .[a2].Resize(m, c + 4).Borders.LineStyle = 1
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|