lundi 7 janvier 2019

Range not working with Excel table using Autofilter from checkbox criteria

What I'm trying to do is use a multiple checkbox form to set filter values based on a table in my "Projects" worksheet. I've been able to successfully get this working on individuals however what I need this to do is take any combination of currently 33 checkboxes to filter rows that meet all criteria selected. Below is what I currently have and it keep kicking back on the range. My range runs columns K:AQ which equal values of 11 to 43 as you'll see below. I appreciate any help you can provide.

Private Sub FilterButton_Click()

Dim wb As Workbook: Set wb = ThisWorkbook 
Dim ws As Worksheet
Set ws = wb.Sheets("Projects")
Dim fld As Long
For fld = 11 To 43
Next

If frmSearch.CheckBox1 = True = True Or _
frmSearch.CheckBox2 = True Or frmSearch.CheckBox3 = True Or _
frmSearch.CheckBox4 = True Or frmSearch.CheckBox5 = True Or _
frmSearch.CheckBox6 = True Or frmSearch.CheckBox7 = True Or _
frmSearch.CheckBox8 = True Or frmSearch.CheckBox9 = True Or _
frmSearch.CheckBox10 = True Or frmSearch.CheckBox11 = True Or _
frmSearch.CheckBox12 = True Or frmSearch.CheckBox13 = True Or _
frmSearch.CheckBox14 = True Or frmSearch.CheckBox15 = True Or _
frmSearch.CheckBox16 = True Or frmSearch.CheckBox17 = True Or _
frmSearch.CheckBox18 = True Or frmSearch.CheckBox19 = True Or _
frmSearch.CheckBox20 = True Or frmSearch.CheckBox21 = True Or _
frmSearch.CheckBox22 = True Or frmSearch.CheckBox23 = True Or _
frmSearch.CheckBox24 = True Or frmSearch.CheckBox25 = True Or _
frmSearch.CheckBox26 = True Or frmSearch.CheckBox27 = True Or _
frmSearch.CheckBox28 = True Or frmSearch.CheckBox29 = True Or _
frmSearch.CheckBox30 = True Or frmSearch.CheckBox31 = True Or _
frmSearch.CheckBox32 = True Or frmSearch.CheckBox33 = True Then

ws.Range("K2:AQ1500").AutoFilter Field:="fld", Criteria1:="<>"

End If
End Sub




Aucun commentaire:

Enregistrer un commentaire