- Sub 生成多栏帐()
- Dim d, arr, ar, br(), m, i, j, s
- Set d = CreateObject("Scripting.Dictionary")
- [A6:S10000] = Empty
- arr = Range("F5:R5")
- ar = Sheet1.UsedRange
- For i = 4 To UBound(ar)
- If ar(i, 7) = Range("A3") Then
- s = ar(i, 4) & ar(i, 7)
- If d(s) = "" Then
- m = m + 1
- ReDim Preserve br(1 To 19, 1 To m)
- d(s) = m
- For j = 1 To 5
- br(j, m) = ar(i, j)
- Next
- For j = 1 To UBound(arr, 2)
- If ar(i, 8) = arr(1, j) Then br(j + 5, m) = ar(i, 12)
- Next
- If ar(i, 8) = "结转" Then br(19, m) = ar(i, 15)
- Else
- For j = 1 To UBound(arr, 2)
- If ar(i, 8) = arr(1, j) Then br(j + 5, d(s)) = br(j + 5, d(s)) + ar(i, 12)
- Next
- If ar(i, 8) = "结转" Then br(19, d(s)) = br(19, d(s)) + ar(i, 12)
- End If
- End If
- Next
- [A6].Resize(m, 19) = Application.Transpose(br)
- Set d = Nothing
- End Sub
复制代码 |