|
直接在“表统计”里点击。- Sub tt()
- Dim wb As Workbook, xRng As Range
- rq = [o3]
- Set xRng = Rows(1).Find(rq)
- If Not xRng Is Nothing Then
- 'Set wb = Workbooks("数据.xls")
- Set wb = Workbooks.Open(ThisWorkbook.Path & "\数据.xls")
- arr = wb.Worksheets(1).[a1].CurrentRegion
- Set d = CreateObject("scripting.dictionary")
- For i = 1 To UBound(arr)
- If IsNumeric(arr(i, 1)) Then
- For j = 2 To UBound(arr, 2)
- xkey = arr(i, 1) & arr(1, j)
- d(xkey) = d(xkey) + arr(i, j)
- Next
- End If
- Next
-
- brr = [a1].CurrentRegion
- c = xRng.Column
- For i = 3 To UBound(brr)
- For j = c - 1 To c + 1
- xkey = brr(i, 1) & brr(2, j)
- brr(i, j) = d(xkey)
- Next
- Next
- [a1].CurrentRegion = brr
- wb.Close False
- End If
- End Sub
复制代码 |
|