Count Date Sequence Based on "Step" Condition in Another Cell

Pepperoni

New Member
Joined
Nov 30, 2021
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hi everyone,

I have tried to look around to answer this myself, but I don't even know if I'm explaining it right to find the information.

I am attempting to make a template that will auto calculate a sequence of dates based on conditions in another cell. For example, if a user was to select 'Weekly' Payslips in B6, the start and end dates in B and C 14, should automatically calculate weekly dates for a period of time from the date entered in B11. However, if they were to select 'Fortnightly' payslips, it would auto change to a fortnightly date range for a number of weeks from the start date in B11 (I have attached a screen shot)

The closest I have found so far is to nest EDATE and Sequence...but from there it just goes silly - as you can see! I need this to auto calculate so there is no potential of an incorrect date range being manually entered.
Any help is much appreciated!
 

Attachments

  • Book1 (version 1).xlsb  -  Read-Only - Excel 2022-.png
    Book1 (version 1).xlsb - Read-Only - Excel 2022-.png
    42 KB · Views: 23

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Welcome to the MrExcel forum!

Try:

Book2
ABCD
1
2
3
4
5
6Payslip PeriodsWeekly
7
8Subsidy Start Date1/1/2022
9Subsidy End Date2/7/2022
10Payable
11Payslip Start Date1/1/2022
12
13Payslip StartPayslip EndPayslip Hours
141/1/20221/7/2022
151/8/20221/14/2022
161/15/20221/21/2022
171/22/20221/28/2022
181/29/20222/4/2022
192/5/20222/11/2022
202/12/20222/18/2022
Sheet7
Cell Formulas
RangeFormula
B14:B39B14=SEQUENCE(26,,B11,IF(B6="Weekly",7,14))
C14:C39C14=B14#+IF(B6="Weekly",6,13)
Dynamic array formulas.
 
Upvote 0
Welcome to the MrExcel forum!

Try:

Book2
ABCD
1
2
3
4
5
6Payslip PeriodsWeekly
7
8Subsidy Start Date1/1/2022
9Subsidy End Date2/7/2022
10Payable
11Payslip Start Date1/1/2022
12
13Payslip StartPayslip EndPayslip Hours
141/1/20221/7/2022
151/8/20221/14/2022
161/15/20221/21/2022
171/22/20221/28/2022
181/29/20222/4/2022
192/5/20222/11/2022
202/12/20222/18/2022
Sheet7
Cell Formulas
RangeFormula
B14:B39B14=SEQUENCE(26,,B11,IF(B6="Weekly",7,14))
C14:C39C14=B14#+IF(B6="Weekly",6,13)
Dynamic array formulas.
This is actually perfect @Eric W Thank you so much.

One last question, could I combine the sequence function in Column B to do the same calculation for a specific number of rows for each payslip period range.
Example:

User Selects 'Fortnightly' and the sequence range displays 13 rows of sequential dates. User selects 'Monthly' and it will display 6 rows of sequential months.

Thank you!
 
Upvote 0
If "Monthly" does that actually mean a calendar month running from the 1st of the month to the last day of the month or does it mean a 4-week period, or something else?
 
Upvote 0
Try this adaptation then.

22 01 21.xlsm
ABC
1
2
3
4
5
6Payslip PeriodsMonthly
7
8Subsidy Start Date1/01/2022
9Subsidy End Date7/02/2022
10Payable
11Payslip Start Date1/01/2022
12
13Payslip StartPayslip End
141/01/202228/01/2022
1529/01/202225/02/2022
1626/02/202225/03/2022
1726/03/202222/04/2022
1823/04/202220/05/2022
1921/05/202217/06/2022
20
Pays
Cell Formulas
RangeFormula
B14:B19B14=LET(p,MATCH(B6,{"Weekly","Fortnightly","Monthly"},0),SEQUENCE(CHOOSE(p,26,13,6),,B11,CHOOSE(p,7,14,28)))
C14:C19C14=B14#+IF(B6="Weekly",6,IF(B6="Monthly",27,13))
Dynamic array formulas.
Cells with Data Validation
CellAllowCriteria
B6ListWeekly,Fortnightly,Monthly
 
Upvote 0
Solution
Try this adaptation then.

22 01 21.xlsm
ABC
1
2
3
4
5
6Payslip PeriodsMonthly
7
8Subsidy Start Date1/01/2022
9Subsidy End Date7/02/2022
10Payable
11Payslip Start Date1/01/2022
12
13Payslip StartPayslip End
141/01/202228/01/2022
1529/01/202225/02/2022
1626/02/202225/03/2022
1726/03/202222/04/2022
1823/04/202220/05/2022
1921/05/202217/06/2022
20
Pays
Cell Formulas
RangeFormula
B14:B19B14=LET(p,MATCH(B6,{"Weekly","Fortnightly","Monthly"},0),SEQUENCE(CHOOSE(p,26,13,6),,B11,CHOOSE(p,7,14,28)))
C14:C19C14=B14#+IF(B6="Weekly",6,IF(B6="Monthly",27,13))
Dynamic array formulas.
Cells with Data Validation
CellAllowCriteria
B6ListWeekly,Fortnightly,Monthly
Amazing! Thank you so much! I would have never found this as I was probably asking all the wrong questions.
Thank you again! Off to practice!!
 
Upvote 0
You're welcome. Thanks for the follow-up. :)

If interested, here is a slightly shorter alternative for B14. ?

22 01 21.xlsm
ABC
1
2
3
4
5
6Payslip PeriodsFortnightly
7
8Subsidy Start Date1/01/2022
9Subsidy End Date7/02/2022
10Payable
11Payslip Start Date1/01/2022
12
13Payslip StartPayslip End
141/01/202214/01/2022
1515/01/202228/01/2022
1629/01/202211/02/2022
1712/02/202225/02/2022
1826/02/202211/03/2022
1912/03/202225/03/2022
2026/03/20228/04/2022
219/04/202222/04/2022
2223/04/20226/05/2022
237/05/202220/05/2022
2421/05/20223/06/2022
254/06/202217/06/2022
2618/06/20221/07/2022
27
Pays
Cell Formulas
RangeFormula
B14:B26B14=LET(p,FIND(LEFT(B6,1),"WFM"),SEQUENCE(CHOOSE(p,26,13,6),,B11,CHOOSE(p,7,14,28)))
C14:C26C14=B46#+IF(B6="Weekly",6,IF(B6="Monthly",27,13))
Dynamic array formulas.
Cells with Data Validation
CellAllowCriteria
B6ListWeekly,Fortnightly,Monthly
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,582
Members
449,089
Latest member
Motoracer88

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