![]() |
CurrentDate + 3 months (arithmetic with dates???)
newbie here, i'm trying to filter a column in a macro for current date + 3
months. here what i got so far: Application.Goto Reference:="Decision_Window" myDecisionWindowColumn = ActiveCell.Column Selection.AutoFilter Field:=myDecisionWindowColumn, Criteria1:=Now(), Operator:=xlAnd, _ Criteria2:=Now() + 3 obviously the "+ 3" doesn't work... please help, thanks in advance, mark |
CurrentDate + 3 months (arithmetic with dates???)
Try
Criteria2:= dateserial(year(date),month(date)+3,day(date)) -- HTH RP (remove nothere from the email address if mailing direct) "mvyvoda" wrote in message ... newbie here, i'm trying to filter a column in a macro for current date + 3 months. here what i got so far: Application.Goto Reference:="Decision_Window" myDecisionWindowColumn = ActiveCell.Column Selection.AutoFilter Field:=myDecisionWindowColumn, Criteria1:=Now(), Operator:=xlAnd, _ Criteria2:=Now() + 3 obviously the "+ 3" doesn't work... please help, thanks in advance, mark |
CurrentDate + 3 months (arithmetic with dates???)
Dim dt as Date
dt = dateserial(year(date),Month(date)+3,day(date)) Application.Goto Reference:="Decision_Window" myDecisionWindowColumn = ActiveCell.Column Selection.AutoFilter Field:=myDecisionWindowColumn, Criteria1:=clng(dt) -- Regards, Tom Ogilvy "mvyvoda" wrote in message ... newbie here, i'm trying to filter a column in a macro for current date + 3 months. here what i got so far: Application.Goto Reference:="Decision_Window" myDecisionWindowColumn = ActiveCell.Column Selection.AutoFilter Field:=myDecisionWindowColumn, Criteria1:=Now(), Operator:=xlAnd, _ Criteria2:=Now() + 3 obviously the "+ 3" doesn't work... please help, thanks in advance, mark |
CurrentDate + 3 months (arithmetic with dates???)
On Fri, 16 Dec 2005 20:56:45 -0000, "Bob Phillips"
wrote: Try Criteria2:= dateserial(year(date),month(date)+3,day(date)) Be careful! You should stipulate first clearly, how you want to calculate in special cases, e.g. Start date = 29 Nov 2005 What is Start date + 3 Month? 29 Feb 2006 does not exist. (1) End Date could be 28 Feb 2006 (like some banks would do) (2) End Date could also be 01 Mar 2006 (like your formula does) Marcus. |
CurrentDate + 3 months (arithmetic with dates???)
Tim and all,
you guys are very helpful!! thanks so much. as of right now the format of the Decision Window Column is 2005-09, 2006-11, etc. when i execute the code below, all of the data is filtered out (i.e. there are no dates shown). i'm not 100% why this is. i appreciate any help you can give. thanks, mark "Tom Ogilvy" wrote: Dim dt as Date dt = dateserial(year(date),Month(date)+3,day(date)) Application.Goto Reference:="Decision_Window" myDecisionWindowColumn = ActiveCell.Column Selection.AutoFilter Field:=myDecisionWindowColumn, Criteria1:=clng(dt) -- Regards, Tom Ogilvy "mvyvoda" wrote in message ... newbie here, i'm trying to filter a column in a macro for current date + 3 months. here what i got so far: Application.Goto Reference:="Decision_Window" myDecisionWindowColumn = ActiveCell.Column Selection.AutoFilter Field:=myDecisionWindowColumn, Criteria1:=Now(), Operator:=xlAnd, _ Criteria2:=Now() + 3 obviously the "+ 3" doesn't work... please help, thanks in advance, mark |
All times are GMT +1. The time now is 11:48 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com