|
- Sub test()
- Dim r%, i%
- Dim arr, brr(1 To 1000, 1 To 13)
- Dim ws As Worksheet
- m = 0
- For Each ws In Worksheets
- With ws
- If .Range("a6") Like "*日期 姓名*" Then
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- c = .Cells(6, .Columns.Count).End(xlToLeft).Column
- arr = .Range("a6").Resize(r - 5, c)
- For i = 3 To UBound(arr)
- If Len(arr(i, 1)) <> 0 And arr(i, 1) <> "合计" Then
- m = m + 1
- brr(m, 1) = arr(i, 1)
- For j = 2 To UBound(arr, 2)
- If Len(arr(1, j)) <> 0 And IsDate(arr(1, j)) Then
- yf = Month(arr(1, j))
- brr(m, yf + 1) = brr(m, yf + 1) + arr(i, j)
- End If
- Next
- End If
- Next
- End If
- End With
- Next
- With Worksheets("sheet1")
- .Range("a5:m" & .Rows.Count).ClearContents
- .Range("a5").Resize(m, UBound(brr, 2)) = brr
- End With
- End Sub
复制代码 |
|