可改用"排除法"
for i= 1 to 999
If Trim(MB1)<>"" and Cells(i, "A") <> Trim(MB1) then goto i01
if Trim(MB2)<>"" and Cells(i, "C") <> Trim(MB2) then goto i01
if Trim(MB3)<>"" and Cells(i, "E") <> Val(MB3) Then goto i01
符合條件..do something...
Dim SrhKey$, T$
For i = 1 To 3
T = Trim(Controls("TextBox" & i).Text) SrhKey = SrhKey & "/" & IIf(T = "", "*", T)
Next i
For R = 2 To UBound(MA1)
Key = "/" & Cells(R, "A") & "/" & Cells(R, "C") & "/" & Cells(R, "E")
If Key Like SrhKey Then '搜尋
'===========
'-----你的程式-----
'===========
End If
Next R作者: dou10801 時間: 2021-7-20 00:10
Sub TEST()
Dim Arr, D1, D2, X, i&, j%, N&
Sheets(2).UsedRange.ClearContents
D1 = [j2]: D2 = [k2]: X = [L2:N2]
Arr = Range([i1], [a65536].End(xlUp))
For i = 2 To UBound(Arr)
If IsDate(D1) Then If CDate(Arr(i, 9)) < D1 Then GoTo i01
If IsDate(D2) Then If CDate(Arr(i, 9)) > D2 Then GoTo i01
For j = 1 To 3
If X(1, j) <> "" And X(1, j) <> Arr(i, Mid(135, j, 1)) Then GoTo i01
Next j
N = N + 1
For j = 1 To UBound(Arr, 2): Arr(N + 1, j) = Arr(i, j): Next
i01: Next i
If N > 0 Then Sheets(2).[a1].Resize(N + 1, UBound(Arr, 2)) = Arr
End Sub