Thanks for the help so far ; I had to adjust a few things because you put the values in the labels in the array where the labels of the projects contain other information too. Giving the following code :
Private Sub CommandButton4_Click()
Dim i As Long, j As Long, x As Long
Dim D() As String, k() As String
ReDim D(1 To 20): ReDim k(1 To 5)
x = 8
j = 0
'Build array of checked items (Projects)
For i = 6 To 25
If Me.Controls("CheckBox" & i).Value = True Then
j = j + 1
D(j) = (Sheets("Tabellen").Cells(x, "S").Value)
x = x + 1
End If
Next i
If j > 0 Then
ReDim Preserve D(1 To j)
Else
MsgBox "Er is niets geselecteerd", , "Projecten"
Exit Sub
End If
'Build array of checked items (Prioriteit)
j = 0
For i = 1 To 5
If Me.Controls("CheckBox" & i).Value = True Then
j = j + 1
k(j) = Me.Controls("Label" & Array(3, 4, 5, 6, 31)(i - 1)).Caption
End If
Next i
If j > 0 Then
ReDim Preserve k(1 To j)
Else
MsgBox "Er is niets geselecteerd", , "Prioriteit"
Exit Sub
End If
'Autofilter
With Sheets("UIT TE VOEREN").AutoFilter.Range
.AutoFilter Field:=20, Criteria1:="true", Operator:=xlFilterValues
.AutoFilter Field:=2, Criteria1:=D, Operator:=xlFilterValues
.AutoFilter Field:=9, Criteria1:=k, Operator:=xlFilterValues
End With
Analyse.Hide
End Sub
while testing I noticed that the arrays don't seem to build up as they should. The filter only works for the first added value, not the others in the array
So if I check the A and B priority it only filters on A priority and hides the B.
Bookmarks