Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

ActiveDocument.Fields .Select

I need to select a rolling 12 months of data when I select a chart.  The field I need to select on is YrMonth which is in the format 12012-01.

sub SetRolling12Mo

ActiveDocument.Fields("YrMonth").Clear

ActiveDocument.Fields("YrMonth").Select "<=" & Year(now()) & "-" & Month(now())

end sub

Any help woudl be appreciated.

2 Replies
lironbaram
Partner - Master III
Partner - Master III

hei

i findit a best practice to have a field in the calnder , monthyear which have the value monthtart of every date

i.e all dates are 01/012012 , 01/12/2011.....

then in your case i would define a varaible with the formula =addmonths(max(monthyear),-11)

then in the macro use this

sub SetRolling12Mo

ActiveDocument.Fields("monthyear").Clear

ActiveDocument.Fields("monthyear").Select ">=" & varaible

end sub

Not applicable
Author

I have also a problem with this? can someone help me.