If statement with multiple date ranges Excel

Anonymous
2022-12-13T23:47:28.063+00:00

Hi,
I am trying to make an employee leave overview chart.
The idea is that when I add a start date and an end date in picture two, the reason code in the cell before those dates is generated on all the dates on picture one that are inbetween all the ranges from picture 2.
Like you can see it worked for the first line. I used:
IF(AND(I5>=Sheet2!F5;'Jaarplan Verlof 2023'!I5<=Sheet2!$C$5);Sheet2!$A$5;"")
but this only workes for the forst row on picture two. How can i make this work for all the date ranges I add in picture two?

270400-schermafbeelding-2022-12-14-om-100654.png
270406-schermafbeelding-2022-12-14-om-100711.png

Microsoft 365 and Office | Excel | For business | Windows
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Herbert Seidenberg 1,201 Reputation points
    2022-12-14T17:40:00.557+00:00

    Excel 365 Pro Plus with Power Pivot and Power Query.
    Leave overview chart.
    Starting with blank slate.
    No formulas, optional VBA macro for chart formatting.
    With Gantt chart.
    https://www.mediafire.com/file/9h1sceshv4fxlm8/12_13_22.xlsm/file
    https://www.mediafire.com/file/n0qhgf5ddlixy0x/12_13_22.pdf/file

    1 person found this answer helpful.
    0 comments No comments

  2. Aung Zaw Min Thwin 306 Reputation points
    2022-12-14T02:15:37.87+00:00

    Hi,

    I don't understand your requirement clearly. But, can try removing "$" in Sheet2 cells as below?

    IF(AND(I5>=Sheet2!F5;'Jaarplan Verlof 2023'!I5<=Sheet2!$C5);Sheet2!$A5;"")

    0 comments No comments

  3. Emily Hua-MSFT 27,866 Reputation points
    2022-12-14T06:14:32.833+00:00

    Hi @YasserBenMessaoud-1625

    Please check whether my following formula is helpful.
    =IF(AND(I$5>=Sheet2!$F5;'Jaarplan Verlof 2023'!I$5<=Sheet2!$C5);Sheet2!$A5;"")

    On my simple sample, I get the following results, you can have a check. Any misunderstandings, you can feel free to post back.
    270302-capture14.png

    270290-capture15.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.