|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
二个条件合并- Sub SKU拆解合并()
- Application.ScreenUpdating = False
- arr = Sheets("原始数据").UsedRange
- zrr = Sheets("关联数据").UsedRange
- Dim tm: tm = Timer
- ReDim brr(1 To 1000000, 1 To 100)
- For i = 2 To UBound(arr)
- st = arr(i, 1) & arr(i, 4)
- For x = 2 To UBound(zrr)
- If zrr(x, 1) & zrr(x, 2) = st Then
- m = m + 1
- For j = 1 To UBound(arr, 2)
- brr(m, j) = arr(i, j)
- Next
- brr(m, 9) = zrr(x, 7)
- brr(m, 10) = zrr(x, 8)
- brr(m, 11) = arr(i, 5) * zrr(x, 8)
- End If
- Next
- Next
- With Sheets("合并数据")
- .UsedRange.Offset(1).Clear
- With .[a2].Resize(m, 11)
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- End With
- Application.ScreenUpdating = True
- MsgBox "共用时:" & Format(Timer - tm) & "秒!"
- End Sub
复制代码
|
|