|
Sub 主营收入月明细()
Dim brr()
Set d = CreateObject("scripting.dictionary")
With Sheets("已开发票明细表")
arr = .Range(Sheets("已开发票明细表").Cells(1, 1), Sheets("已开发票明细表").Cells(Rows.Count, 40).End(xlUp))
End With
k = 1
y = 1
For i = 2 To UBound(arr)
If Trim(arr(i, 1)) <> "" And Trim(arr(i, 40)) <> "" Then
ReDim Preserve brr(1 To UBound(arr), 1 To y)
t = d(Trim(arr(i, 1)))
If t = "" Then
k = k + 1
d(Trim(arr(i, 1))) = k
t = k
brr(k, 1) = arr(i, 1)
End If
lh = d(Trim(arr(i, 40)))
If lh = "" Then
y = y + 1
ReDim Preserve brr(1 To UBound(arr), 1 To y)
d(Trim(arr(i, 40))) = y
lh = y
brr(1, y) = arr(i, 40)
End If
brr(t, lh) = brr(t, lh) + arr(i, 23)
End If
Next i
With Sheets("主营收入月明细")
.UsedRange.Clear
.[c7].Resize(k, y) = brr
.[c7].Resize(k, y).Borders.LineStyle = 1
End With
Set d = Nothing
End Sub
|
|