Zacariah171
New Member
- Joined
- Apr 2, 2019
- Messages
- 28
I have a timesheet with dates in column A, starting in A7, with a header, "Date", in A6. In A4 I have a dropdown menu with the dates that are being used in my Date column (there is a header in A3, "Date") and if I select one of the dates from the dropdown menu, everything filters just fine. I'd like to try and apply a second criteria to filter the dates by month. I added a second dropdown menu in cell P4, with a header, "Date", in P3 and used a list of months: January, February, etc. The way I have it, the "month" filter is being applied but isn't working because my dates don't match "January". My dates are formatted like 1/31/2020. Is there a way to filter dates that are in that format by using the name of the month? I also tried reformatting my dates to January 31, 2020 but my January filter still didn't work because they didn't match exactly. Basically, what I'm trying to achieve is leaving my date formatting as 1/31/2020 and having one criteria filter by the specific date and a second criteria filter by the month. Is this possible? Pleas let me know if more information is needed. Any advice is greatly appreciated!
'This filters the column by the date. I found this code from Excel Macro Mastery.
Sub AdvancedFilter()
Dim rgData As Range
Dim rgCriteria As Range
Set rgData = ThisWorkbook.Worksheets("Timesheet Table").Range("A6").CurrentRegion
Set rgCriteria = ThisWorkbook.Worksheets("Timesheet Table").Range("A3").CurrentRegion
rgData.AdvancedFilter xlFilterInPlace, rgCriteria
End Sub
'This is what I thought should filter the column by the month.
Sub AdvancedFilterByMonth()
Dim rgData As Range
Dim rgCriteria As Range
Set rgData = ThisWorkbook.Worksheets("Timesheet Table").Range("A6").CurrentRegion
Set rgCriteria = ThisWorkbook.Worksheets("Timesheet Table").Range("P3").CurrentRegion
rgData.AdvancedFilter xlFilterInPlace, rgCriteria
End Sub
Format 1
Date
12/30/2019
12/30/2019
12/30/2019
12/30/2019
12/30/2019
12/30/2019
1/2/2020
1/3/2020
1/3/2020
1/3/2020
1/3/2020
1/3/2020
1/3/2020
Format 2
Date
December 30, 2019
December 30, 2019
December 30, 2019
December 30, 2019
December 30, 2019
December 30, 2019
January 2, 2020
January 3, 2020
January 3, 2020
January 3, 2020
January 3, 2020
January 3, 2020
January 3, 2020
'This filters the column by the date. I found this code from Excel Macro Mastery.
Sub AdvancedFilter()
Dim rgData As Range
Dim rgCriteria As Range
Set rgData = ThisWorkbook.Worksheets("Timesheet Table").Range("A6").CurrentRegion
Set rgCriteria = ThisWorkbook.Worksheets("Timesheet Table").Range("A3").CurrentRegion
rgData.AdvancedFilter xlFilterInPlace, rgCriteria
End Sub
'This is what I thought should filter the column by the month.
Sub AdvancedFilterByMonth()
Dim rgData As Range
Dim rgCriteria As Range
Set rgData = ThisWorkbook.Worksheets("Timesheet Table").Range("A6").CurrentRegion
Set rgCriteria = ThisWorkbook.Worksheets("Timesheet Table").Range("P3").CurrentRegion
rgData.AdvancedFilter xlFilterInPlace, rgCriteria
End Sub
Format 1
Date
12/30/2019
12/30/2019
12/30/2019
12/30/2019
12/30/2019
12/30/2019
1/2/2020
1/3/2020
1/3/2020
1/3/2020
1/3/2020
1/3/2020
1/3/2020
Format 2
Date
December 30, 2019
December 30, 2019
December 30, 2019
December 30, 2019
December 30, 2019
December 30, 2019
January 2, 2020
January 3, 2020
January 3, 2020
January 3, 2020
January 3, 2020
January 3, 2020
January 3, 2020