|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
参与一下。。。- Sub ykcbf() '//2024.2.21
- Dim arr, brr
- c = 2
- ReDim a(1 To c), ft(1 To c)
- With Sheets("Sheet1")
- a(1) = .[b1]
- a(2) = .[b2]
- End With
- With Sheets("Sheet2")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .Range("a2:h" & r)
- End With
- ReDim brr(1 To UBound(arr), 1 To UBound(arr, 2))
- For i = 1 To UBound(arr)
- fft = 1
- ft(1) = IIf(a(1) = Empty Or arr(i, 1) = a(1), 1, 0)
- fft = fft * ft(1)
- ft(2) = IIf(a(2) = Empty Or arr(i, 2) = a(2), 1, 0)
- fft = fft * ft(2)
- If fft = 1 Then
- m = m + 1
- For j = 1 To UBound(arr, 2)
- brr(m, j) = arr(i, j)
- Next
- End If
- Next
- With Sheets("Sheet1")
- .UsedRange.Offset(4).ClearContents
- With .[a5].Resize(m, 8)
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- End With
- MsgBox "OK!"
- End Sub
复制代码
|
|