|
参与一下。。。- Sub ykcbf() '//2024.1.7
- Dim arr, brr
- c = 4
- ReDim a(1 To c), ft(1 To c)
- With Sheets("查询数据")
- a(1) = .[b1]
- a(2) = .[d1]
- a(3) = .[f1]
- a(4) = .[h1]
- End With
- b = [{1,2,3,4,7,8,9}]
- With Sheets("出入库明细")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .Range("a4:j" & r)
- End With
- ReDim brr(1 To UBound(arr), 1 To 7)
- For i = 1 To UBound(arr)
- fft = 1
- s = CDate(arr(i, 3))
- ft(3) = IIf(a(3) = Empty Or s >= a(3), 1, 0)
- fft = fft * ft(3)
- ft(4) = IIf(a(4) = Empty Or s <= a(4), 1, 0)
- fft = fft * ft(4)
- ft(1) = IIf(a(1) = Empty Or arr(i, 8) = a(1), 1, 0)
- fft = fft * ft(1)
- ft(2) = IIf(a(2) = Empty Or arr(i, 4) = a(2), 1, 0)
- fft = fft * ft(2)
- If fft = 1 Then
- m = m + 1
- brr(m, 1) = m
- For j = 2 To UBound(b)
- brr(m, j) = arr(i, b(j))
- Next
- End If
- Next
- With Sheets("查询数据")
- .UsedRange.Offset(2).ClearContents
- With .[a3].Resize(m, 7)
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- End With
- MsgBox "OK!"
- End Sub
复制代码
|
|