Dies verwendet Arrays und wird ziemlich schnell sein. Diese
Sub foo()
Dim tickSht As Worksheet
Dim restSht As Worksheet
Dim disaSht As Worksheet
Dim tickArr() As Variant
Dim restArr() As Variant
Dim disaArr() As Variant
Dim outArr() As Variant
Dim i&, k&, j&, r&, d&
Dim dishr As Boolean
Dim tichr As Boolean
Set tickSht = ThisWorkbook.Worksheets("Tickers") 'ensure that this is the correct sheet name
Set restSht = ThisWorkbook.Worksheets("Restricted") 'ensure that this is the correct sheet name
Set disaSht = ThisWorkbook.Worksheets("Disabled") 'ensure that this is the correct sheet name
'load arrays
'if you have a title row then change the "A1" to "A2" or the first row.
'If your data is in a differect column then change the column.
With disaSht
disaArr = .Range("A1", .Cells(.Rows.Count, 1).End(xlUp)).Value
End With
With restSht
restArr = .Range("A1", .Cells(.Rows.Count, 1).End(xlUp)).Value
End With
r = Application.Evaluate("SUM(countifs(" & tickSht.Range("A1", tickSht.Cells(tickSht.Rows.Count, 1).End(xlUp)).Address & _
"," & restSht.Range("A1", restSht.Cells(restSht.Rows.Count, 1).End(xlUp)).Address & "))")
d = Application.Evaluate("SUM(countifs(" & tickSht.Range("A1", tickSht.Cells(tickSht.Rows.Count, 1).End(xlUp)).Address & _
"," & disaSht.Range("A1", disaSht.Cells(disaSht.Rows.Count, 1).End(xlUp)).Address & "))")
With tickSht
tickArr = .Range("A1", .Cells(.Rows.Count, 1).End(xlUp)).Value
ReDim outArr(1 To UBound(tickArr, 1) - d - t, 1 To 1)
k = 1
For i = LBound(tickArr, 1) To UBound(tickArr, 1)
dishr = False
tichr = False
For j = LBound(disaArr, 1) To UBound(disaArr, 1)
If disaArr(j, 1) = tickArr(i, 1) Then dishr = True
Next j
For j = LBound(restArr, 1) To UBound(restArr, 1)
If restArr(j, 1) = tickArr(i, 1) Then tichr = True
Next j
If Not tichr And Not dishr Then
outArr(k, 1) = tickArr(i, 1)
k = k + 1
End If
Next i
.Range("B1").Resize(UBound(outArr, 1), 1).Value = outArr
End With
End Sub
geht davon aus, dass die Daten in der Spalte A auf allen drei Platten und dass es keine Titelzeile (n). Wenn es anders ist, müssen einige Anpassungen vorgenommen werden.
Dies ist insofern dynamisch, als es immer die Ausdehnung der Daten auf allen drei Blättern findet, die sie in Arrays lädt und durch diese iteriert.
Die Verwendung von Arrays begrenzt die Häufigkeit, mit der vba auf das Blatt in Excel zugreift, daher wird es mit größeren Datensätzen schneller.
Was haben Sie versucht - einen Code? – jcoppens