|
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- With Worksheets("收费单据")
- ReDim brr(1 To 7)
- brr(1) = .Range("f3")
- brr(2) = .Range("b3")
- brr(3) = .Range("b4")
- brr(4) = .Range("b5")
- brr(5) = .Range("d5")
- brr(6) = .Range("f5")
- brr(7) = .Range("d4")
- .PrintOut
- .Range("f3") = Format(Val(.Range("f3")) + 1, "0000")
- .Range("b3:b5,d4") = ""
- End With
- With Worksheets("收费明细")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- If r = 1 Then
- m = 2
- Else
- For i = 2 To r
- If .Cells(i, 1) = brr(1) Then
- Exit For
- End If
- Next
- If i <= r Then
- m = i
- Else
- m = r + 1
- End If
- End If
- .Cells(m, 1).Resize(1, UBound(brr)) = brr
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:g" & r)
- End With
- For i = 1 To UBound(arr)
- If InStr(arr(i, 7), "小区") <> 0 Then
- xm = Split(arr(i, 7), "小区")(0) & "小区"
- If Not d.exists(xm) Then
- ReDim brr(1 To 7)
- brr(1) = xm
- Else
- brr = d(xm)
- End If
- If arr(i, 2) = Date Then
- brr(2) = brr(2) + 1
- brr(3) = brr(3) + arr(i, 4)
- brr(4) = brr(4) + arr(i, 6)
- End If
- brr(5) = brr(5) + 1
- brr(6) = brr(6) + arr(i, 4)
- brr(7) = brr(7) + arr(i, 6)
- d(xm) = brr
- End If
- Next
- With Worksheets("汇总统计")
- .Range("a4:g13").ClearContents
- .Range("a4").Resize(d.Count, UBound(brr)) = Application.Transpose(Application.Transpose(d.items))
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|