AlbertRBrowne
New Member
- Joined
- Jun 25, 2011
- Messages
- 6
I am using a Form with the code below to filter a range on my spreadsheet the filter works ok with field 1 and 2 commented out. But if I activate them the wildcard "*" fails and no records are selected. Field 1 contains a date field 2 contains a calculated week number. If I add a value to these fields the filter works ok. The form boxes contains the * by default. Field 1 and 2 are text boxes the rest are combo boxes. Can anyone help to get this to work?
Thanks,
Albert
Thanks,
Albert
Code:
'Apply Filter
Private Sub FilterButton_Click()
Dim FDate As String, FWeek As String, FSeries As String, FModel As String, FProductType As String, FDept As String, FRootCause As String
ActiveSheet.AutoFilterMode = False
FDate = Filter.DateTxtBox.Value
FWeek = Filter.WeekTxtBox.Value
FSeries = Filter.SeriesCmbBox.Value
FModel = Filter.ModelTypeCmbBox.Value
FProductType = Filter.ProductTypeCmbBox.Value
FDept = Filter.DeptCmbBox.Value
FRootCause = Filter.RootCauseCmbBox.Value
With ActiveSheet
.AutoFilterMode = False
.Range("D29:N279").AutoFilter
.Range("D30:N279").AutoFilter field:=1 ', Criteria1:=FDate, visibledropdown:=False
.Range("D30:N279").AutoFilter field:=2 ', Criteria1:=FWeek, visibledropdown:=False
.Range("D30:N279").AutoFilter field:=3, visibledropdown:=False
.Range("D30:N279").AutoFilter field:=4, Criteria1:=FSeries, visibledropdown:=False
.Range("D30:N279").AutoFilter field:=5, Criteria1:=FModel, visibledropdown:=False
.Range("D30:N279").AutoFilter field:=6, Criteria1:=FProductType, visibledropdown:=False
.Range("D30:N279").AutoFilter field:=7, visibledropdown:=False
.Range("D30:N279").AutoFilter field:=8, visibledropdown:=False
.Range("D30:N279").AutoFilter field:=9, Criteria1:=FDept, visibledropdown:=False
.Range("D30:N279").AutoFilter field:=10, Criteria1:=FRootCause, visibledropdown:=False
.Range("D30:N279").AutoFilter field:=11, visibledropdown:=False
End With
Unload Me
End Sub