+ Reply to Thread
Results 1 to 5 of 5

CurrentDate + 3 months (arithmetic with dates???)

  1. #1
    mvyvoda
    Guest

    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. #2
    Bob Phillips
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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. #3
    Tom Ogilvy
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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




  4. #4
    Marcus O. M. Grabe
    Guest

    Re: CurrentDate + 3 months (arithmetic with dates???)

    On Fri, 16 Dec 2005 20:56:45 -0000, "Bob Phillips"
    <[email protected]> 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.

  5. #5
    mvyvoda
    Guest

    Re: 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" <[email protected]> wrote in message
    > news:[email protected]...
    > > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1