修改如下,請再測試看看,謝謝
If T = "" Or T1 = "" Then Brr(i, j) = "": GoTo 99
修改為--> If T = "" Then Brr(i, j) = "": GoTo 99
If T = T2 Then
修改為--> If T = T1 Then作者: samwang 時間: 2021-10-7 11:50
Sub test()
Dim Arr, Drr, Brr(), Crr(), T, XMax, XMin
Tm = Timer
Arr = Range([資料庫!b6], [資料庫!b65536].End(3))
'Drr = Sheets("資料庫").Range("i6:ama" & UBound(Arr) + 5)
Drr = Sheets("資料庫").Range("i6:p" & UBound(Arr) + 5)
[比對!b6].Resize(UBound(Arr)) = Arr
ReDim Brr(1 To UBound(Arr), 1 To 8) '1 to 1000
ReDim Crr(1 To UBound(Arr), 1 To 1)
With Sheets("比對")
Arr = .Range("i3:p4")
For i = 1 To UBound(Drr)
Crr(i, 1) = 0
For j = 1 To UBound(Arr, 2)
T = Drr(i, j): XMin = Arr(1, j): XMax = Arr(2, j)
If XMin = "" Or T = "" Then Brr(i, j) = "": GoTo 99
If T < XMin Or T > XMax Then
Brr(i, j) = 0
Else
Brr(i, j) = 1: Crr(i, 1) = Crr(i, 1) + 1
End If
99: Next j
Next i
.Range("h6").Resize(UBound(Crr)) = Crr
.Range("i6").Resize(UBound(Brr), UBound(Brr, 2)) = Brr
End With
MsgBox Timer - Tm
End Sub作者: oak0723-1 時間: 2021-10-8 18:16
Sub test()
Dim Arr, Drr, Brr(), Crr(), T, XMax, XMin, R%, C%
Tm = Timer
With Sheets("資料庫")
R = .[b6].End(4).Row
C = .Cells(5, Columns.Count).End(1).Column
Arr = .Range(.[b6], .Cells(R, 2))
Drr = .Range(.[i6], .Cells(R, C))
End With
With Sheets("比對")
.[b6].Resize(UBound(Arr)) = Arr
ReDim Brr(1 To UBound(Arr), 1 To UBound(Drr, 2))
ReDim Crr(1 To UBound(Arr), 1 To 1)
C = .Cells(3, Columns.Count).End(1).Column
Arr = .Range(.[i3], .Cells(4, C))
For i = 1 To UBound(Drr)
Crr(i, 1) = 0
For j = 1 To UBound(Arr, 2)
T = Drr(i, j): XMin = Arr(1, j): XMax = Arr(2, j)
If XMin = "" Or T = "" Then Brr(i, j) = "": GoTo 99
If T < XMin Or T > XMax Then
Brr(i, j) = 0
Else
Brr(i, j) = 1: Crr(i, 1) = Crr(i, 1) + 1
End If
99: Next j
Next i
.Range("h6").Resize(UBound(Crr)) = Crr
.Range("i6").Resize(UBound(Brr), UBound(Brr, 2)) = Brr
End With
MsgBox Timer - Tm
End Sub作者: oak0723-1 時間: 2021-10-9 14:23
...
...
With Sheets("比對")
.[b6].Resize(UBound(Arr)) = Arr
ReDim Brr(1 To UBound(Arr), 1 To UBound(Drr, 2))
ReDim Crr(1 To UBound(Arr), 1 To 1)
C1 = .Cells(3, Columns.Count).End(1).Column
If C1 > C Then C = C Else C = C1
Arr = .Range(.[i3], .Cells(4, C))
For i = 1 To UBound(Drr)
...
...