|
Sub 不定条件个数查询()
With Sheets("数据库")
R = .Cells(Rows.Count, 1).End(xlUp).Row
If R < 2 Then MsgBox "数据库为空!": End
ar = .Range("a1:w" & R)
End With
With Sheets("订单")
gg = .[c15]
bm = .[c16]
dh = .[e15]
gys = .[g15]
fl = .[g16]
rq = .[h16]
rr = Array(gg, 9, bm, 16, dh, 6, gys, 7, fl, 8, rq, 13)
Dim arr()
ReDim arr(1 To 7, 1 To 2)
For i = 0 To UBound(rr) Step 2
If rr(i) <> "" Then
n = n + 1
arr(n, 1) = rr(i)
arr(n, 2) = rr(i + 1)
End If
Next i
If n = "" Then MsgBox "请至少输入一个查询条件!": End
Dim brr()
ReDim brr(1 To UBound(ar), 1 To 7)
For i = 2 To UBound(ar)
k = 0
For s = 1 To n
lh = arr(s, 2)
zd = arr(s, 1)
If ar(i, lh) = zd Then
k = k + 1
End If
Next s
If k = n Then
m = m + 1
brr(m, 1) = m
For j = 9 To 14
brr(m, j - 7) = ar(i, j)
Next j
End If
Next i
If m = "" Then MsgBox "没有符合条件的数据!": End
.UsedRange.Offset(17) = Empty
.[b18].Resize(m, UBound(brr, 2)) = brr
End With
MsgBox "ok!"
End Sub
|
|