how to program a filter for a three week look

J

joethecm

How do I program a filter that will automatically bring up a three week look
ahead starting with the previous monday?
 
J

JackD

The easy way is to turn on the macro recorder.
Then create a filter which filters tasks within a certain range.
Then turn off the macro recorder.
Edit the code so that it uses variables for the criteria values.
Write some code to find the previous monday and the date three weeks in
advance.

Here is code to find monday and the 3 week period.
Dim lastMonday, threeWeeksLater as Date
lastMonday = Now()

While Not Weekday(lastMonday) = vbMonday
lastMonday = lastMonday - 1
Wend

threeWeeksLater = lastMonday + 21
 
N

Neil Peterson

I use this macro to set the filters that I then use to view the tasks:

Sub SetThreeWeek()

Dim TodaysDate As Variant
Dim sdate1 As String
Dim sdate2 As String


TodaysDate = Now
nday = Weekday(TodaysDate)
sdate1 = CStr(DateAdd("d", -(7 + nday - 2), TodaysDate))
sdate2 = CStr(DateAdd("d", 7 + 6 - nday, TodaysDate))

'Update Filters used to view tasks within project
FilterEdit Name:="Math3weeks", TaskFilter:=True, Create:=True,
OverwriteExisting:=True, FieldName:="Start", test:="is greater than or
equal to", Value:=sdate1, ShowInMenu:=True, ShowSummaryTasks:=True
FilterEdit Name:="Math3weeks", TaskFilter:=True, FieldName:="",
NewFieldName:="Start", test:="is less than or equal to", Value:=sdate2,
Operation:="And", ShowSummaryTasks:=True
FilterEdit Name:="Math3weeks", TaskFilter:=True, FieldName:="",
NewFieldName:="% Complete", test:="is less than", Value:=100,
Operation:="And", ShowSummaryTasks:=True
FilterEdit Name:="Math3weeks", TaskFilter:=True, FieldName:="",
NewFieldName:="Resource Group", test:="contains", Value:="Math",
Operation:="And", ShowSummaryTasks:=True
FilterEdit Name:="Math3weeks", TaskFilter:=True, Parenthesis:=True,
FieldName:="", NewFieldName:="Finish", test:="is greater than or equal
to", Value:=sdate1, Operation:="Or", ShowSummaryTasks:=True
FilterEdit Name:="Math3weeks", TaskFilter:=True, FieldName:="",
NewFieldName:="Finish", test:="is less than or equal to", Value:=sdate2,
Operation:="And", ShowSummaryTasks:=True
FilterEdit Name:="Math3weeks", TaskFilter:=True, FieldName:="",
NewFieldName:="% Complete", test:="is less than", Value:=100,
Operation:="And", ShowSummaryTasks:=True
FilterEdit Name:="Math3weeks", TaskFilter:=True, FieldName:="",
NewFieldName:="Resource Group", test:="contains", Value:="Math",
Operation:="And", ShowSummaryTasks:=True

and so on.....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top