I have a userform that allows users to select a client, then month, then goal, then objective. The code for each sets the autofilter to filter the results on a data sheet. I would like to change the month from a single month selection to a range. I am new to VBA and I am unsure how to do this... I assume I will need 2 month selectors one for the start and one for the end.
I have provided my current code below.
Forms - DataReport
Microsoft Excel Objects: This Workbook
I have provided my current code below.
Forms - DataReport
Code:
Private Sub UserForm_Initialize()
Me.ComboBox2.Enabled = False
Me.ComboBox3.Enabled = False
Me.ComboBox4.Enabled = False
Me.RunButton.Enabled = False
End Sub
Private Sub ComboBox1_Change()
DataReport.ComboBox2.Clear
If Objective5m.FilterMode = True Then: Objective5m.ShowAllData
Objective5m.Range("A1").AutoFilter field:=14, Criteria1:="=" & DataReport.ComboBox1.Value
Call FillCombobox(Objective5m.Range("X2", Objective5m.Cells(Rows.Count, "X").End(xlUp)).SpecialCells(xlCellTypeVisible), DataReport.ComboBox2)
Me.ComboBox2.Enabled = True
End Sub
Private Sub ComboBox2_Change()
DataReport.ComboBox3.Clear
Objective5m.Range("A1").AutoFilter field:=24, Criteria1:="=" & DataReport.ComboBox2.Value
Call FillCombobox(Objective5m.Range("P2", Objective5m.Cells(Rows.Count, "P").End(xlUp)).SpecialCells(xlCellTypeVisible), DataReport.ComboBox3)
Me.ComboBox3.Enabled = True
End Sub
Private Sub ComboBox3_Change()
DataReport.ComboBox4.Clear
Objective5m.Range("A1").AutoFilter field:=16, Criteria1:="=" & DataReport.ComboBox3.Value
Call FillCombobox(Objective5m.Range("Q2", Objective5m.Cells(Rows.Count, "Q").End(xlUp)).SpecialCells(xlCellTypeVisible), DataReport.ComboBox4)
Me.ComboBox4.Enabled = True
Me.RunButton.Enabled = True
End Sub
Private Sub ComboBox4_Change()
Objective5m.Range("A1").AutoFilter field:=17, Criteria1:="=" & DataReport.ComboBox4.Value
End Sub
Private Sub RunButton_Click()
Unload DataReport
Call Filtered
Call AMasterBuild
End Sub
Private Sub CancelButton_Click()
Unload DataReport
End Sub
Microsoft Excel Objects: This Workbook
Code:
Private Sub Workbook_Open()
DataReport.ComboBox1.Clear
Columns("N:N").Select
Range("A2:HX29921").Sort Key1:=Range("N2"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Objective5m.Range("A1").AutoFilter
Call FillCombobox(Objective5m.Range("N2", Objective5m.Cells(Rows.Count, "N").End(xlUp)), DataReport.ComboBox1)
DataReport.Show
End Sub