I'm trying to filter a table by the first/last half of the month using a userform to select the range. My userform has a combobox to select the month and then a set of optionbuttons to pick either the first or last half of the month (1-15/16-31). Currently I cant even get it to filter by month using my existing code.
Code:
Private Sub FilterButton_Click()
Dim MyInput As Date
Dim MyInput2 As Date
Dim Month As Date
If DateFilter.OptionButton1.Value = True Then
Day1 = "1"
Day2 = "15"
Else
Day1 = "16"
Day2 = "31"
End If
MyInput = Month("Month")
MyInput2 = Month("Month")
MyInput3 = JobBox
Worksheets("Timesheet").Range("Table_Joined_Query").AutoFilter Field:=1, Criteria1:=">=" & MyInput, Operator:=xlAnd, Criteria2:="<=" & MyInput2
If MyInput3 <> "" Then Worksheets("Timesheet").Range("Table_Joined_Query").AutoFilter Field:=2, Criteria1:=MyInput3 Else
Worksheets("Timesheet").Range("Table_Joined_Query").Sort Key1:=Range("Table1"), Order1:=xlAscending, Header:=xlYes, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Unload Me
End Sub