hi guys,
I am stumped on why my code is not working and could use another set of eyes to look and possibly see where my mistake is. I have a spreadsheet that I want to filter using a command button. I have 2 fields to select the filter. I have drop down lists in cells F3 and G3 that the user will make their selections then hit the button for the spreadsheet to be filtered on both criteria. Below is the start of the code (there can be 24 combinations of selections when complete). When I test this, nothing happens. The sheet does not filter and no error message, which makes me think I have done something stupid and just can't see it. Any input would help. Thank you!
Kat
I am stumped on why my code is not working and could use another set of eyes to look and possibly see where my mistake is. I have a spreadsheet that I want to filter using a command button. I have 2 fields to select the filter. I have drop down lists in cells F3 and G3 that the user will make their selections then hit the button for the spreadsheet to be filtered on both criteria. Below is the start of the code (there can be 24 combinations of selections when complete). When I test this, nothing happens. The sheet does not filter and no error message, which makes me think I have done something stupid and just can't see it. Any input would help. Thank you!
Kat
VBA Code:
Sub Button37_Click() 'filter Exp Log by Impact Cost and Status
ActiveSheet.Unprotect Password:="1234"
Dim list1 As String, list2 As String
list1 = Range("F3")
list2 = Range("G3")
If list1 = "Open" And list2 = "1 Construction" Then
With Worksheets("ExposureLog").Range("A7:S2508")
.AutoFilter Field:=13, Criteria1:="Open"
.AutoFilter Field:=6, Criteria1:="1 Construction"
End With
ElseIf list1 = "Open" And list2 = "2 Architectural & Engr" Then
With Worksheets("ExposureLog").Range("A7:S2508")
.AutoFilter Field:=13, Criteria1:="Open"
.AutoFilter Field:=6, Criteria1:="2 Architectural & Engr"
End With
ElseIf list1 = "Open" And list2 = "3 FF&E" Then
With Worksheets("ExposureLog").Range("A7:S2508")
.AutoFilter Field:=13, Criteria1:="Open"
.AutoFilter Field:=6, Criteria1:="3 FF&E"
End With
ElseIf list1 = "Open" And list2 = "4 Security & Equipment" Then
With Worksheets("ExposureLog").Range("A7:S2508")
.AutoFilter Field:=13, Criteria1:="Open"
.AutoFilter Field:=6, Criteria1:="4 Security & Equipment"
End With
ElseIf list1 = "Open" And list2 = "5 One Time Expenses" Then
With Worksheets("ExposureLog").Range("A7:S2508")
.AutoFilter Field:=13, Criteria1:="Open"
.AutoFilter Field:=6, Criteria1:="5 One Time Expenses"
End With
ElseIf list1 = "Open" And list2 = "7 Program Staffing" Then
With Worksheets("ExposureLog").Range("A7:S2508")
.AutoFilter Field:=13, Criteria1:="Open"
.AutoFilter Field:=6, Criteria1:="7 Program Staffing"
End With
ElseIf list1 = "Open" And list2 = "8 Program Artwork" Then
With Worksheets("ExposureLog").Range("A7:S2508")
.AutoFilter Field:=13, Criteria1:="Open"
.AutoFilter Field:=6, Criteria1:="8 Program Artwork"
End With
ElseIf list1 = "Open" And list2 = "P PROGRAM COST" Then
With Worksheets("ExposureLog").Range("A7:S2508")
.AutoFilter Field:=13, Criteria1:="Open"
.AutoFilter Field:=6, Criteria1:="P PROGRAM COST"
End With
ElseIf list1 = "Open" And list2 = "ALL" Then
With Worksheets("ExposureLog").Range("A7:S2508")
.AutoFilter Field:=13, Criteria1:="Open"
.AutoFilter Field:=6, Criteria1:=Array("1 Construction", "2 Architectural & Engr", "3 FF&E", "4 Security & Equipment", "5 One Time Expenses", "7 Program Staffing", "8 Program Artwork", "P PROGRAM COST"), _
Operator:=xlFilterValues
End With 'End of OPEN
End If
ActiveSheet.Protect Password:="1234"
End Sub