1.不限定单位
Sub 收款人查询()
Dim i, j, arr, brr
If InputBox("Please input the Password") <> "ysg4763659" Then Exit Sub
Sheets("收款人查询").Visible = xlSheetVisible
Sheets("收款人查询").[a6:n100000].ClearContents
arr = Sheets("支付明细").UsedRange
ReDim brr(1 To UBound(arr), 1 To 59)
For i = 5 To UBound(arr)
If arr(i, 29) Like Sheets("收款人查询").Range("n1").Value Then
m = m + 1
For j = 1 To 14
brr(m, 1) = arr(i, 3)
brr(m, 2) = arr(i, 2)
brr(m, 3) = arr(i, 9)
brr(m, 4) = arr(i, 16)
brr(m, 5) = arr(i, 17)
brr(m, 6) = arr(i, 19)
brr(m, 7) = arr(i, 21)
brr(m, 8) = arr(i, 24)
brr(m, 9) = arr(i, 41)
brr(m, 10) = arr(i, 9)
brr(m, 11) = arr(i, 26)
brr(m, 12) = arr(i, 29)
brr(m, 13) = arr(i, 46)
brr(m, 14) = arr(i, 49)
Next
End If
Next
Sheets("收款人查询").[a6].Resize(m, 14) = brr
Range("a6:n1000").Sort Key1:=Range("j6"), Order1:=xlAscending, Key2:=Range("n6"), Order2:=xlAscending
Range("a6").Select
MsgBox "查询结束,请按确定键!"
End Sub
2.限定单位
Sub 单位收款人查询()
Dim i, j, arr, brr
If InputBox("Please input the Password") <> "ysg4763659" Then Exit Sub
Sheets("单位收款人查询").Visible = xlSheetVisible
Sheets("单位收款人查询").[a7:m100000].ClearContents
arr = Sheets("支付明细").UsedRange
ReDim brr(1 To UBound(arr), 1 To 59)
For i = 5 To UBound(arr)
If arr(i, 9) Like Sheets("单位收款人查询").Range("m1").Value Then
If arr(i, 29) Like Sheets("单位收款人查询").Range("m2").Value Then
m = m + 1
For j = 1 To 13
brr(m, 1) = arr(i, 3)
brr(m, 2) = arr(i, 2)
brr(m, 3) = arr(i, 9)
brr(m, 4) = arr(i, 16)
brr(m, 5) = arr(i, 17)
brr(m, 6) = arr(i, 19)
brr(m, 7) = arr(i, 21)
brr(m, 8) = arr(i, 24)
brr(m, 9) = arr(i, 41)
brr(m, 10) = arr(i, 26)
brr(m, 11) = arr(i, 29)
brr(m, 12) = arr(i, 46)
brr(m, 13) = arr(i, 49)
Next
End If
End If
Next
Sheets("单位收款人查询").[a7].Resize(m, 13) = brr
Range("a7:m1000").Sort Key1:=Range("i7"), Order1:=xlAscending
Range("a7").Select
MsgBox "查询结束,请按确定键!"
End Sub
查询同一单位数据,结果不一样,请高手指点
|