- Sub test()
- Dim Sht As Worksheet, I&, J&, Dic, Ar, Br, K&, S!
- Set Dic = CreateObject("scripting.dictionary")
- Ar = Sheets("应收账").Range("a1").CurrentRegion '30天的月份应清除32列数据
- ReDim Br(1 To UBound(Ar) - 1 + 3, 1 To 8)
- For I = 2 To UBound(Ar, 2)
- For J = 2 To UBound(Ar)
- If Ar(J, I) <> "" Then
- K = K + 1
- Br(K, 2) = "挂账": Br(K, 3) = Ar(J, I): Br(K, 5) = Ar(J, 1)
- S = Ar(J, I) + S
- End If
- Next
- Br(K + 1, 2) = "挂帐合计:": Br(K + 1, 3) = S
- K = K + 3
- S = 0
- Br(K, 1) = "备注"
- If K > 0 Then
- With Sheets("" & Day(Ar(1, I)) & "")
- .Range("b18:I1000").Clear
- .Range("b18").Resize(K, 8) = Br
- With .Range("b5:i" & (K + 17))
- .Borders.LineStyle = xlContinuous
- .Borders.ColorIndex = xlAutomatic
- End With
- End With
- Else
- With Sheets("" & Day(Ar(1, I)) & "")
- .Range("b18:I1000").Clear
- End With
- End If
- ReDim Br(1 To UBound(Ar) - 1 + 3, 1 To 8)
- 'Sheets (Day(Ar(1, I)))
- K = 0
- Next
- End Sub
复制代码 |