Consulting

Results 1 to 18 of 18

Thread: Solved: Date formula

  1. #1
    VBAX Contributor
    Joined
    Apr 2008
    Posts
    136
    Location

    Solved: Date formula

    Hi guys,

    Wondering if anyone can help. Im struggling!

    Came up with this formula. but need to look at a range i.e. compare 5 columns

    [Formula]=IF(ISERROR(TODAY()-C3),"Error1", IF(AND(TODAY()-C3>0,TODAY()-C3>VLOOKUP(B3,H1:I6,2, FALSE)), "pas de data", IF(AND(TODAY()-C3<0,TODAY()-C3>-VLOOKUP(B3,H1:I6,2, FALSE)),C3,"pas de data")))[/Formula]

    There are 5 columns.
    I need to calculate if date in any of the columns falls within period then show date

    Please see attached. I have put under past and future the results i expect to see.

    Please let me know if not clear.

    Many Thanks in advance

  2. #2
    VBAX Contributor
    Joined
    Apr 2008
    Posts
    136
    Location
    forgot to attach!

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I think I am confused, but try this array formula

    =IF(ISNUMBER(MATCH(TRUE,ABS(TODAY()-IF(C3:G3<>"NULL",C3:G3,100000))<VLOOKUP($B3,$L$1:$M$6,2,FALSE),0)),
    INDEX(C3:G3,MATCH(TRUE,ABS(TODAY()-IF(C3:G3<>"NULL",C3:G3,100000))<VLOOKUP($B3,$L$1:$M$6,2,FALSE),0)),"No Dates")
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    VBAX Contributor
    Joined
    Apr 2008
    Posts
    136
    Location
    thanks xld but this just brings up No dates every time evvn for correct dates entered. Id like to two formulas, one for past and one for future To work out if date in one of the five columns comes in the past and future period based on column B which is the key.

    Example if u look at B7 that says T which accounts for 120 days. there is a date in D7- 12/12/10. For the past column it should show No dates as this date is in the future. For future it should show date as it is in the future and falls within 120 ahead period.


    many thanks.

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Maybe these

    =IF(ISNUMBER(MATCH(TRUE,IF(($C3:$G3<>"NULL")*(--$C3:$G3<TODAY()),$C3:$G3,100000)-TODAY()<VLOOKUP($B3,$L$1:$M$6,2,FALSE),0)),
    INDEX($C3:$G3,MATCH(TRUE,IF(($C3:$G3<>"NULL")*(--$C3:$G3<TODAY()),$C3:$G3,100000)-TODAY()<VLOOKUP($B3,$L$1:$M$6,2,FALSE),0)),"No Dates")

    and

    =IF(ISNUMBER(MATCH(TRUE,IF(($C3:$G3<>"NULL")*(--$C3:$G3>TODAY()),$C3:$G3,100000)-TODAY()<VLOOKUP($B3,$L$1:$M$6,2,FALSE),0)),
    INDEX($C3:$G3,MATCH(TRUE,IF(($C3:$G3<>"NULL")*(--$C3:$G3>TODAY()),$C3:$G3,100000)-TODAY()<VLOOKUP($B3,$L$1:$M$6,2,FALSE),0)),"No Dates")
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    VBAX Contributor
    Joined
    Apr 2008
    Posts
    136
    Location
    Keeps saying No dates, for everything I try. Would you be able to explain the formula, please. Thanks

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You need to array enter the formulae.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  8. #8
    VBAX Contributor
    Joined
    Apr 2008
    Posts
    136
    Location
    sorry i dont understand

  9. #9
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Edit the formula, then hit Ctrl-Shift-Enter, not just Enter.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  10. #10
    VBAX Contributor
    Joined
    Apr 2008
    Posts
    136
    Location
    Thanks,
    that works but the calculation is not working properly. if for example the date 15/09/2007 and key is Q which 183 days 15/09/2007 is more than 183 days old so so cell should display No dates
    I will have a long list of rows, will i have to CTRL+SHIFT+Enter for all cells for each row?

  11. #11
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Try these two

    =IF(ISNUMBER(MATCH(TRUE,IF(($C3:$G3<>"NULL")*(--$C3:$G3<TODAY()),TODAY()-$C3:$G3,100000)<VLOOKUP($B3,$L$1:$M$6,2,FALSE),0)),
    INDEX($C3:$G3,MATCH(TRUE,IF(($C3:$G3<>"NULL")*(--$C3:$G3<TODAY()),TODAY()-$C3:$G3,100000)<VLOOKUP($B3,$L$1:$M$6,2,FALSE),0)),"No Dates")

    and

    =IF(ISNUMBER(MATCH(TRUE,IF(($C3:$G3<>"NULL")*(--$C3:$G3<TODAY()),TODAY()-$C3:$G3,100000)<VLOOKUP($B3,$L$1:$M$6,2,FALSE),0)),
    INDEX($C3:$G3,MATCH(TRUE,IF(($C3:$G3<>"NULL")*(--$C3:$G3<TODAY()),TODAY()-$C3:$G3,100000)<VLOOKUP($B3,$L$1:$M$6,2,FALSE),0)),"No Dates")

    You would drag-copy the formula, so you only need Ctrl-Shift-Enter for the first two.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  12. #12
    VBAX Contributor
    Joined
    Apr 2008
    Posts
    136
    Location
    thanks, but both these formulas are the same for past and future

  13. #13
    VBAX Contributor
    Joined
    Apr 2008
    Posts
    136
    Location
    the first one works!

  14. #14
    VBAX Contributor
    Joined
    Apr 2008
    Posts
    136
    Location
    the formula for past works but not future, i tried using > for future but doesnt work properly

  15. #15
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I gave you the wrong for future, should have been

    =IF(ISNUMBER(MATCH(TRUE,IF(($C3:$G3<>"NULL")*(--$C3:$G3>TODAY()),$C3:$G3-TODAY(),100000)<VLOOKUP($B3,$L$1:$M$6,2,FALSE),0)),
    INDEX($C3:$G3,MATCH(TRUE,IF(($C3:$G3<>"NULL")*(--$C3:$G3>TODAY()),$C3:$G3-TODAY(),100000)<VLOOKUP($B3,$L$1:$M$6,2,FALSE),0)),"No Dates")
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  16. #16
    VBAX Contributor
    Joined
    Apr 2008
    Posts
    136
    Location
    thank you for your efforts. but this still doesn't seem to work.. i even array entered formula, but when a future date for correct period is given it doesn't seem to change, just says 'No dates'..?

  17. #17
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Well it worked for me on the test workbook that you provided.

    If you provide a better test workbook I will look and see if I can spot any problems.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  18. #18
    VBAX Contributor
    Joined
    Apr 2008
    Posts
    136
    Location
    thanks, this works now. May be there is something wrong with my Excel at home.

Posting Permissions

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