+ Reply to Thread
Results 1 to 16 of 16

Formula for variable date ranges in IF(LOGICAL TEST)

  1. #1
    Registered User
    Join Date
    08-02-2019
    Location
    London
    MS-Off Ver
    Most recent
    Posts
    7

    Formula for variable date ranges in IF(LOGICAL TEST)

    Hi,

    I am trying to make a formula that works something like;

    =IF([LOGICAL TEST]Date x<=Date y BUT Date x>Date z, [IF TRUE]Cell A, [IF FALSE]Cell A +1 row down AND +1 row down from Date x in the LOGICAL TEST part)

    Essentially I am trying to make a model in which a specific value corresponds to any time between 2 dates. The value that corresponds to that range of dates is used until the date in the model (which changes) exceeds that given date range. Once that happens I want to next cell below Cell A to be used AND the date range in the logical test to change as well.

    Any help to work out this formula or suggestions for a different approach much appreciated

    Cheers,
    Dan
    Last edited by dan_apple; 08-08-2019 at 09:51 AM.

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: value associated with a date range

    If you can show us what you are working with, we might be able to make some suggetions. To upload a file (actual or mock up) click 'Go Advanced' at the bottom of the reply box, then click 'Manage Attachments' and follow the menu to upload the file.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Registered User
    Join Date
    08-02-2019
    Location
    London
    MS-Off Ver
    Most recent
    Posts
    7

    Re: value associated with a date range

    associated file
    Attached Files Attached Files

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,978

    Re: value associated with a date range

    This makes no sense to me at all - sorry!

    Referring to F3: I want the value of this cell to equal the value in col C according to the date in col F which corresponds to the appropriate date range in col B
    Excel 2016 (Windows) 32 bit
    B
    C
    D
    E
    F
    3
    22/05/2008
    0.049978
    15/04/2008
    4
    01/09/2008
    0.049978
    27/04/2008
    5
    08/12/2008
    0.053652
    09/05/2008
    6
    24/02/2009
    0.053652
    22/05/2008
    7
    01/09/2009
    0.049978
    03/06/2008
    8
    18/03/2010
    0.053652
    16/06/2008
    9
    16/07/2010
    0.049978
    28/06/2008
    10
    01/09/2010
    0.049978
    11/07/2008
    11
    03/11/2010
    0.053652
    23/07/2008
    12
    26/01/2011
    0.053652
    05/08/2008
    13
    01/03/2011
    0.053652
    17/08/2008
    14
    04/07/2011
    0.049978
    30/08/2008
    15
    22/08/2011
    0.049978
    11/09/2008
    16
    24/11/2011
    0.053652
    24/09/2008
    17
    13/02/2012
    0.053652
    06/10/2008
    18
    01/03/2012
    0.053652
    19/10/2008
    Sheet: Sheet1
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: value associated with a date range

    If you were using B4 and B7 as you date range, the the formula would be
    Please Login or Register  to view this content.
    This would be If the value in col F is <= col B(earlier date) And (not But) >= col B )later date) Then col G = col C corresponding value to col F, Else col G = col C Offset 1 row value.

    I agree with AliGW, The objective does not really follow a logical pattern. and the formula would need to be tailored to each specific entry because of the date range variations. Maybe you can put some thought into it and give us a clearer picture of what you want to do.

  6. #6
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,448

    Re: value associated with a date range

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    As you are new here, I am adding the link https://www.mrexcel.com/forum/excel-...ate-range.html
    Please take a moment to read forum rules

  7. #7
    Registered User
    Join Date
    08-02-2019
    Location
    London
    MS-Off Ver
    Most recent
    Posts
    7

    Re: value associated with a date range

    (Re post by JLGWhiz)

    What you have explained here is exactly what I am looking for.
    You don't think it possible to have a single formula (which applies for all col F entries) like what you have suggested but the logical test earlier and later date (i.e.: the date range) changes when no value is found to complete the calculation?

  8. #8
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: value associated with a date range

    Quote Originally Posted by dan_apple View Post
    (Re post by JLGWhiz)

    What you have explained here is exactly what I am looking for.
    You don't think it possible to have a single formula (which applies for all col F entries) like what you have suggested but the logical test earlier and later date (i.e.: the date range) changes when no value is found to complete the calculation?
    I am not good enough with formulas to write one that would do what you want. The varying date ranges are not in a consistent pattern, and would need some sort of criteria established to determine when to change the range and what to change it to. As I look at the example, I cannot see that logical pattern and the narrative in he OP does not gve any clues to the reasoning used to select the specific ranges. I won't say it can't be done, I will just say that I can't do it with the current information.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,978

    Re: value associated with a date range

    Dan - thank you for your PM. No, you may not open a new thread on this issue, however you can:

    1. Change the thread title to make it clearer.
    2. Add more detail to the thread by posting to it again.

  10. #10
    Registered User
    Join Date
    08-02-2019
    Location
    London
    MS-Off Ver
    Most recent
    Posts
    7

    Re: value associated with a date range

    A revised version of the original question with example;

    --------------------------------------------------------
    I am trying to make a formula that works something like;

    =IF([LOGICAL TEST]Date x<=Date y BUT Date x>Date z, [IF TRUE]Cell A which is associated with Date x, [IF FALSE]in the LOGICAL TEST part, +1 row down for Date y and +1 row down for Date z until Date x falls between Day y and z. Then use the Cell associated with that Date x)

    Attached is an example of what the result should be which may best explain my issue

    Thanks
    D
    Attached Files Attached Files

  11. #11
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: value associated with a date range

    That example in the second file is much clearer as to what you are trying to do. Unfurtunately, as I said before, I am not good enough with formulas to offer a solution, but I am sure someone on this site can. It will likely have to be an array formula using a VLookup. But I will leave that to the formula gurus. Thanks for the clarification.

  12. #12
    Registered User
    Join Date
    08-02-2019
    Location
    London
    MS-Off Ver
    Most recent
    Posts
    7

    Re: value associated with a date range

    Ok, thanks for the help

  13. #13
    Registered User
    Join Date
    08-02-2019
    Location
    London
    MS-Off Ver
    Most recent
    Posts
    7

    Re: value associated with a date range

    Still unsolved

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,978

    Re: value associated with a date range

    YOu didn't change the thread title to give clearer details of what you are trying to do - I advised this back in post #9.

  15. #15
    Registered User
    Join Date
    08-02-2019
    Location
    London
    MS-Off Ver
    Most recent
    Posts
    7

    Re: value associated with a date range

    How do i do that?

    Thanks,
    D

  16. #16
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,978

    Re: value associated with a date range

    Administrative Note:

    To edit the thread title, open the original post to edit and then click on Go Advanced (bottom right) to access the area where you can edit your title.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 03-21-2018, 09:25 AM
  2. Check a date range and return value based on the date range
    By KeithCar in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-13-2015, 12:55 PM
  3. Highlight a date range if today's date falls within that range
    By sdarnell in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-01-2014, 10:03 AM
  4. Search date range +/- 7 days and return date that falls within range
    By tlafferty in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-13-2013, 03:26 PM
  5. Replies: 9
    Last Post: 06-21-2012, 03:46 PM
  6. [SOLVED] Calculate how many days in one date range fall into a second date range
    By globalpontoon in forum Excel General
    Replies: 2
    Last Post: 05-08-2012, 03:02 PM
  7. Replies: 4
    Last Post: 03-18-2011, 07:02 AM

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