|
楼主 |
发表于 2023-5-31 18:59
|
显示全部楼层
老师们看看我这么写有没有问题,有什么弊端
纯新手,还请指教
Sub SZchaxun()
'收支查询
Dim d, ar, arr, n&, m%, i&, j%
Set d = CreateObject("Scripting.Dictionary")
Sheets("收支查询").Range("B6:Q999").ClearContents
ar = Sheets("收支查询").[A1:Q999]
br = Sheets("收支查询").[A6:Q999]
arr = Sheets("根数据").Range("A1:YN" & Sheets("根数据").[A36656].End(3).Row)
For i = 2 To UBound(ar, 2)
d(ar(5, i)) = UBound(arr, 2)
Next
For i = 1 To UBound(arr)
If i = 1 Then
For j = 1 To UBound(arr, 2)
If d.exists(arr(1, j)) Then d(arr(1, j)) = j
Next
Else
If (ar(2, 5) = (arr(i, 10)) Or ar(2, 5) = "") _
And (ar(2, 7) = arr(i, 3) Or ar(2, 7) = "") _
And (ar(2, 9) = Month(arr(i, 16)) Or ar(2, 9) = "") _
And (IIf(ar(2, 11) = "应付金额", arr(i, 25) <> 0, ar(2, 11) = arr(i, 25)) _
Or (IIf(ar(2, 11) = "未收金额", arr(i, 38) <> 0, ar(2, 11) = arr(i, 38)) _
Or (IIf(ar(2, 11) = "未收应付", arr(i, 38) <> 0 Or arr(i, 25) <> 0, ar(2, 11) = arr(i, 38)) _
Or ar(2, 11) = ""))) Then
n = n + 1: m = 1
For Each x In d.items
m = m + 1
br(n, m) = arr(i, x)
Next
End If
End If
Next
Sheets("收支查询").[A6:Q999] = br
MsgBox "完成"
End Sub |
|