|
- Private Sub 统计_Click()
- Dim LastRow As Long, i As Long, m As Long, n As Long
- Dim d As Object
- Dim Arr, Result()
-
- Set d = CreateObject("Scripting.Dictionary")
- For Each sht In Worksheets
- If sht.Name <> Me.Name Then
- Arr = sht.Range("A1").CurrentRegion
- For i = 2 To UBound(Arr)
- If d.Exists(Arr(i, 1)) = False Then
- n = n + 1
- d(Arr(i, 1)) = n
- ReDim Preserve Result(1 To 5, 1 To n)
- Result(1, n) = Arr(i, 1)
- m = n
- Else
- m = d(Arr(i, 1))
- End If
- Result(Asc(Arr(i, 2)) - 63, m) = Result(Asc(Arr(i, 2)) - 63, m) + 1
- Next i
- End If
- Next sht
-
- LastRow = Cells(Rows.Count, 1).End(xlUp).Row
- If LastRow > 1 Then
- Range(Rows(2), Rows(LastRow)).Delete
- End If
- Range("A2").Resize(n, 5) = Application.Transpose(Result)
- Range("A1").CurrentRegion.Borders.Weight = xlThin
- End Sub
复制代码 |
|