Macro to recognise quarterly (calendar) increments and apply relevant filter

FJMD1003

New Member
Joined
Mar 9, 2011
Messages
16
Hi all,

I am currently using the code below to filter a sheet based on 2 criteria:

1. Whether a product is ordered
2. Whether this order occurs next quarter (e.g. Q3 2011).

I would like to automate the next quarter filter, so that the macro simply knows that, if we're in q3 2011, to filter for q4 2011 results or if we're in q4 2011, to filter for q1 2012 results etc.

Quarters are:
Jan - march
April - June
July - Sep
Oct - dec

I have the individual dates of all the order occurences stored on the same sheet.

Thanks ,

Fred

Code:
Sub Filter_CPIPCatManQ3()
'
' Filter_Q1 Macro
'
 Sheets("Sheet 1").Select
Range("A1").Select
    ActiveSheet.Protect Password:="Password", DrawingObjects:=True, _
        contents:=True, Scenarios:=True, _
        userinterfaceonly:=True
    ActiveSheet.EnableAutoFilter = True
If ActiveSheet.AutoFilterMode Then
  If ActiveSheet.FilterMode = True Then
       ActiveSheet.ShowAllData
  End If
End If
    ActiveSheet.Range("$D$12:$AE$118").AutoFilter Field:=3, Criteria1:= _
        "Tiles Ordered"
    ActiveSheet.Range("$D$12:$AE$118").AutoFilter Field:=10, Criteria1:= _
        "Q3 2011"
End Sub
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top