Return first Monday in April from one date and first Monday in current year April if another is blank

SaraWitch

Active Member
Joined
Sep 29, 2015
Messages
322
Office Version
  1. 365
Platform
  1. Windows
Hello peeps,

I call upon your expertise again!

I have a start date in A2 and an end date in B2. I want a formula in C2 to return the first Monday in April before the A2 date. I also want a formula in D2 (E2 from example below) to return the date of the first Monday in April of the current year if no date is entered in B2 but to return the date in B2 if one is entered.

For example:
Auto move row.xlsm
ABCDE
1Start DateEnd DateFirst Monday in April before Start DateI can get first Monday in month, but not April'sFirst April Monday in Current Year if B2 empty or B2 date
211/11/2023Should be 03/04/202306/11/2023Should be 03/04/2023
310/10/2021Should be 05/04/202104/10/2021Should be 03/04/2023
403/01/2024Should be 03/04/202301/01/2024Should be 03/04/2023
512/12/202210/10/2023Should be 04/04/202205/12/2022Should be 10/10/2023
604/04/2022Should be 04/04/202204/04/2022Should be 03/04/2023
703/04/2022Should be 05/04/202104/04/2022Should be 03/04/2023
802/02/202304/04/2023Should be 03/04/202306/02/2023Should be 04/04/2023
929/09/202203/01/2024Should be 04/04/202205/09/2022Should be 03/01/2024
1029/09/2022Should be 04/04/202205/09/2022Should be 03/04/2023
Sheet3
Cell Formulas
RangeFormula
D2:D10D2=IF(A2=0,"",A2-DAY(A2)+8-WEEKDAY(A2-DAY(A2)+6))
Cells with Data Validation
CellAllowCriteria
A1:E10Any value


I can return the first Monday of a date's month (column D), but not April's. I've also tried breaking down the dates into years first, but I'm ending up with more columns than I feel I need.

Any help would be gratefully received. :)
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
A different approach that you can consider.

Cell Formulas
RangeFormula
H2:H9H2=LOOKUP(A2,$K$1:$K$9,$K$1:$K$9)
I2:I9I2=IF(B2,LOOKUP(B2,$K$1:$K$9,K$1:$K$9),$K$4)
K1:K9K1=WORKDAY.INTL(DATE(2020+ROW()-1,4,0),1,"0111111")


or


T202401a.xlsm
ABHI
1Start DateEnd Date
202-Apr-23Mon 04-04-22Mon 03-04-23
303-Apr-22Mon 05-04-21Mon 03-04-23
403-Apr-2204-Apr-22Mon 05-04-21Mon 04-04-22
502-Apr-22Mon 05-04-21Mon 03-04-23
602-Apr-2203-Apr-22Mon 05-04-21Mon 05-04-21
702-Apr-2203-Apr-23Mon 05-04-21Mon 03-04-23
801-Apr-25Mon 01-04-24Mon 03-04-23
901-Apr-2508-Apr-25Mon 01-04-24Mon 07-04-25
10
1b_4
Cell Formulas
RangeFormula
H2:H9H2=LET(b,{43927;44291;44655;45019;45383;45754;46118;46482;46846},LOOKUP(A2,b,b))
I2:I9I2=LET(b,{43927;44291;44655;45019;45383;45754;46118;46482;46846},IF(B2,LOOKUP(B2,b,b),45019))
 
Last edited:
Upvote 1
If the above works for you and If you do not want to see the details of the formula,
you can build your own function with Excel 365.
With Name Manager, Name the function something appropriate and user friendly and
put the Lambda details in the value area.

T202401a.xlsm
ABHI
1Start DateEnd Date
202-Apr-23Mon 04-04-22Mon 03-04-23
303-Apr-22Mon 05-04-21Mon 03-04-23
403-Apr-2204-Apr-22Mon 05-04-21Mon 03-04-23
502-Apr-22Mon 05-04-21Mon 03-04-23
602-Apr-2203-Apr-22Mon 05-04-21Mon 03-04-23
702-Apr-2203-Apr-23Mon 05-04-21Mon 03-04-23
801-Apr-25Mon 01-04-24Mon 03-04-23
901-Apr-2508-Apr-25Mon 01-04-24Mon 03-04-23
10
1b_4
Cell Formulas
RangeFormula
H2:H9H2=StartD(A2)
I2:I9I2=EndD(B2)
Lambda Functions
NameFormula
EndD=LAMBDA(EndDateCell,LET(s,EndDateCell,b,{43927;44291;44655;45019;45383;45754;46118;46482;46846},IF('1b_4'!XEV1,LOOKUP('1b_4'!XEV1,b,b),45019)))
StartD=LAMBDA(Start,LET(s,Start,b,{43927;44291;44655;45019;45383;45754;46118;46482;46846},LOOKUP(s,b,b)))
 
Upvote 1
Thanks for the feedback.
If you want to try the Lambda, try the example. If you want additional information, please advise.
N.B. You can customize the terminology etc. for your environment.
Consider
- how to make function use-friendly (name for function, name(s) for input, ...)
- the Lambda states the inputs required
- how to adapt it for the next fiscal year
 
Upvote 1
Thanks very much; I really appreciate your comments and I am glad that you reviewed alternative with Excel.

I noticed that the post did not include an edit. I renamed the function and included the edit.

T202401a.xlsm
ABGH
1 -- V3 with Lambda --
2Start DateEnd Date
302-Apr-2304-Apr-2203-Apr-23
403-Apr-2205-Apr-2103-Apr-23
503-Apr-2204-Apr-2205-Apr-2104-Apr-22
602-Apr-2205-Apr-2103-Apr-23
702-Apr-2203-Apr-2205-Apr-2105-Apr-21
802-Apr-2203-Apr-2305-Apr-2103-Apr-23
901-Apr-2501-Apr-2403-Apr-23
1001-Apr-2508-Apr-2501-Apr-2407-Apr-25
11
1bb
Cell Formulas
RangeFormula
G3:G10G3=FYE_Day1(A3)
H3:H10H3=FYE_B(B3)
Lambda Functions
NameFormula
FYE_B=LAMBDA(cellrefDate,LET(d, cellrefDate, YE_Day1, WORKDAY.INTL(DATE(2020 + SEQUENCE(21, , 0, 1), 4, 0), 1, "0111111"), IF(d = "", LOOKUP(TODAY(), YE_Day1, YE_Day1), LOOKUP(d, YE_Day1, YE_Day1))))
FYE_Day1=LAMBDA(cellrefDate,LET(d,cellrefDate,YE_Day1,WORKDAY.INTL(DATE(2020+SEQUENCE(21,,0,1),4,0),1,"0111111"),LOOKUP(d,YE_Day1)))
 
Upvote 1
T202401a.xlsm
ABCDEF
1Start DateEnd DateFirst Monday in Start MonthFirst April Monday in 2023 First April Monday in Applicable Year
211-Nov-23Mon 06-Nov-23Mon 03-Apr-23Mon 01-Apr-24
310-Oct-21Mon 04-Oct-21Mon 03-Apr-23Mon 01-Apr-24
403-Jan-24Mon 01-Jan-24Mon 03-Apr-23Mon 01-Apr-24
512-Dec-2210-Oct-23Mon 05-Dec-22Mon 03-Apr-23Mon 03-Apr-23
604-Apr-22Mon 04-Apr-22Mon 03-Apr-23Mon 01-Apr-24
703-Apr-22Mon 04-Apr-22Mon 03-Apr-23Mon 01-Apr-24
802-Feb-2304-Apr-23Mon 06-Feb-23Mon 03-Apr-23Mon 03-Apr-23
929-Sep-2203-Jan-24Mon 05-Sep-22Mon 03-Apr-23Mon 01-Apr-24
1029-Sep-22Mon 05-Sep-22Mon 03-Apr-23Mon 01-Apr-24
11
1b
Cell Formulas
RangeFormula
D2:D10D2=WORKDAY.INTL(A2-DAY(A2),1,"0111111")
E2:E10E2=WORKDAY.INTL(DATE(2023,4,0),1,"0111111")
F2:F10F2=WORKDAY.INTL(DATE(IF(B2,YEAR(B2),YEAR(TODAY())),4,0),1,"0111111")
 
Upvote 0
Thank you, Dave. This isn't quite what I need though.

For column C (your column E), I need the first Monday in the April before the start date in column A.

For column E (your column F), if there's no date in column B, I need the first Monday in this fiscal year's April (so for January to March 2024 dates, it needs to be 03/04/2023 (sorry, I didn't make this clear in original post)); otherwise, the date in column B.

I've put what the dates should be in my first example, but here's another for dates in January-April 2024:
MrExcel Queries.xlsm
ABCDE
1Start DateEnd DateFirst Monday in April before Start DateI can get first Monday in month, but not April'sFirst April Monday in Current Year if B2 empty or B2 date
203/01/2024Should be 03/04/202301/01/2024Should be 03/04/2023
304/02/2024Should be 03/04/202305/02/2024Should be 03/04/2023
431/03/2024Should be 03/04/202304/03/2024Should be 03/04/2023
510/02/202412/02/2024Should be 03/04/202305/02/2024Should be 12/02/2023
601/04/2024Should be 01/04/202401/04/2024Should be 01/04/2024
710/04/2024Should be 01/04/202401/04/2024Should be 01/04/2024
812/04/202414/04/2024Should be 01/04/202401/04/2024Should be 14/04/2024
Sheet3
Cell Formulas
RangeFormula
D2:D8D2=IF(A2=0,"",A2-DAY(A2)+8-WEEKDAY(A2-DAY(A2)+6))
Cells with Data Validation
CellAllowCriteria
A1:E8Any value

Not sure if this can be done...?
 
Upvote 0
T202401a.xlsm
ABCD
1Start DateEnd Date
203-Jan-2403-Apr-2303-Apr-23
304-Feb-2403-Apr-2303-Apr-23
431-Mar-2403-Apr-2303-Apr-23
510-Feb-2412-Feb-2403-Apr-2303-Apr-23
601-Apr-2401-Apr-2401-Apr-24
710-Apr-2401-Apr-2401-Apr-24
812-Apr-2414-Apr-2401-Apr-2401-Apr-24
1bb
Cell Formulas
RangeFormula
C2:C8C2=LET(yc,DATE(YEAR(TODAY()),4,0),yp,DATE(YEAR(TODAY())-1,4,0),IF(A2<=yc,WORKDAY.INTL(yp,1,"0111111"),WORKDAY.INTL(yc,1,"0111111")))
D2:D8D2=LET(yc,DATE(YEAR(TODAY()),4,0),yp,DATE(YEAR(TODAY())-1,4,0),IF(OR(B2>"",A2<=yc),WORKDAY.INTL(yp,1,"0111111"),WORKDAY.INTL(yc,1,"0111111")))
 
Upvote 0
For column E (your column F), if there's no date in column B, I need the first Monday in this fiscal year's April (so for January to March 2024 dates, it needs to be 03/04/2023 (sorry, I didn't make this clear in original post)); otherwise, the date in column B.
When you say "this fiscal year", do you mean the fiscal year of the date in columna A or the fiscal year of the current date (as in TODAY())?

And what is your fiscal year? There are many different ones depending on country, state:

Fiscal year - Wikipedia
 
Upvote 0
Wow! Thank you so much, Dave - this works a treat!

I just tweaked the D2 formula to:
Excel Formula:
=IF(B2=0,LET(yc,DATE(YEAR(TODAY()),4,0),yp,DATE(YEAR(TODAY())-1,4,0),IF(OR(B2>"",A2<=yc),WORKDAY.INTL(yp,1,"0111111"),WORKDAY.INTL(yc,1,"0111111"))),B2)

Thank you! 😊


When you say "this fiscal year", do you mean the fiscal year of the date in columna A or the fiscal year of the current date (as in TODAY())?

And what is your fiscal year? There are many different ones depending on country, state
Yes, sorry @felixstraube, I know fiscal years differ from county to country, and even organisations, but in this case the new fiscal year starts on the first Monday in April. I was considering VLOOKUP, but Dave's formulas have worked perfectly 😊
 
Upvote 0

Forum statistics

Threads
1,215,639
Messages
6,125,967
Members
449,276
Latest member
surendra75

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top