|
- Sub 测试() ''答题专用套路--by:学习使我快乐
- Dim i, j, k, m, n, arr, brr, crr, drr
- Dim r As Range, rng As Range
- Sheet1.Activate
- Dim dic As Object, key As String, keys, items
- Set dic = CreateObject("scripting.dictionary")
- For i = 2 To 12
- Set rng = Range("A" & i)
- If rng.MergeArea.Count > 1 Then
- For k = 1 To rng.MergeArea.Count
- Set r = rng.Range("B" & k)
- If r.MergeArea.Count > 1 Then
- For j = 1 To r.MergeArea.Count
- key = rng.Cells(1, 1) & r.Cells(1, 1)
- dic(key) = dic(key) + rng.Cells(k + j - 1, 3)
- Next
- k = k + r.MergeArea.Count - 1
- Else
- key = rng.Cells(1, 1) & r.Cells(1, 1)
- dic(key) = dic(key) + rng.Cells(k, 3)
- End If
- Next
- i = i + rng.MergeArea.Count - 1
- End If
- Next
- arr = Range("E1").CurrentRegion
- For i = 2 To UBound(arr)
- key = arr(i, 1) & arr(i, 2)
- arr(i, 4) = dic(key)
- Next
- Range("E1").Resize(UBound(arr), UBound(arr, 2)) = arr
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|