Create a macro button to show due dates "this week" or "this month"


New Member
Nov 27, 2015

I am trying to create a macro button that shows due dates for "this week" and "the next two weeks" and "next month". I have delivery due dates in column K in a spreadsheet and at the click of a button, I would like to display only the rows that have due dates for this week, etc.

Also, I am not creating the macros in our live spreadsheet; I am using a copy of the spreadsheet in case I make an error. Once I have created the macro buttons that work, how do I get them into our main spreadsheet?

Thank you in advance for any help you can provide.


Active Member
Mar 6, 2008
Can you not use the conditional formatting which has a dates this week/month function? - I use Excel 2013 not sure if this available on any other versions


New Member
Sep 12, 2015
I have had a bit of a play with this. My solution would be four macros
One for each button (this week, next fortnight, next month)
Here they are;

Sub Macro1()
' This week
Dim FilType As Integer
FilType = 1
Call GetRange(FilType)
End Sub

Sub Macro2()
' Next Fortnight
Dim FilType As Integer
FilType = 2
Call GetRange(FilType)

End Sub

Sub Macro3()
' Next month
Dim FilType As Integer
FilType = 3
Call GetRange(FilType)

End Sub
Sub GetRange(FilType)
Dim CurDate As Date
Dim CurWkDay As Integer
Dim WkStart As Date
Dim WkEnd As Date
Dim RangeA As Variant
Dim RangeB As Variant
Dim FilStart As Date
Dim FilEnd As Date
CurDate = Date
CurWkDay = ((CurDate - 2) Mod 7) + 1 ' Day 1 is Monday
CurWkStart = (CurDate - CurWkDay) + 1
CurWkEnd = CurWkStart + 6 ' Week ends on Sunday
Select Case FilType
Case 1 ' This week
FilStart = CurWkStart
FilEnd = CurWkEnd
Case 2 ' Next fortnight
FilStart = CurWkEnd + 1
FilEnd = CurWkEnd + 15
Case 3 ' Next Month
FilStart = DateSerial(Year(CurDate), Month(CurDate) + 1, 1)

FilEnd = DateSerial(Year(FilStart), Month(FilStart) + 1, 0)
End Select
RangeA = ">=" & Format(FilStart, "DDMMMYY")
RangeB = "<=" & Format(FilEnd, "DDMMMYY")
ActiveSheet.Range("K:K").AutoFilter Field:=1, Criteria1:= _
RangeA, Operator:=xlAnd, Criteria2:=RangeB

End Sub

Hope this helps

Forum statistics

Latest member

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...