|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
参与一下。。。
- Sub ykcbf() '//2024.12.11
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- Set d1 = CreateObject("Scripting.Dictionary")
- arr = Sheets("汇总").UsedRange
- For j = 3 To UBound(arr, 2)
- If arr(1, j) <> Empty Then st = arr(1, j)
- s = st & "|" & arr(3, j)
- d1(s) = j
- Next
- arr = Sheets("数据").UsedRange
- ReDim brr(1 To 10000, 1 To 100)
- For i = 3 To UBound(arr)
- If arr(i, 1) <> Empty Then
- s = arr(i, 1)
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = arr(i, 1)
- brr(m, 2) = arr(i, 2)
- End If
- r = d(arr(i, 1))
- For j = 4 To UBound(arr, 2) Step 2
- s = arr(1, j) & "|" & arr(i, 3)
- If d1.exists(s) Then c = d1(s)
- brr(r, c) = brr(r, c) + arr(i, j + 1)
- s = arr(1, j) & "|" & arr(2, j)
- If d1.exists(s) Then c = d1(s)
- brr(r, c) = arr(i, j)
- Next
- End If
- Next
- With Sheets("汇总")
- .UsedRange.Offset(3).ClearContents
- .[a4].Resize(m, 14) = brr
- ActiveWindow.DisplayZeros = False
- End With
- Set d = Nothing
- Set d1 = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
3
查看全部评分
-
|