Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default 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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding months to dates should account for 28-30-31 day months Graham Excel Worksheet Functions 3 February 1st 06 12:06 PM
months between 2 dates!!! speary Excel Discussion (Misc queries) 1 August 19th 05 03:22 PM
Need More Help on Dates to Months Xandlyn Excel Worksheet Functions 4 March 12th 05 12:50 PM
Months and Dates adn4n Excel Programming 2 April 17th 04 10:01 PM
Dates to months and calculating values for their months jigsaw2 Excel Programming 1 September 5th 03 01:35 PM


All times are GMT +1. The time now is 10:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"