Row duplicate for each month.

wikus

Active Member
Joined
May 2, 2010
Messages
318
Office Version
  1. 365
Hi,
The source sheet have a start date and end date columns.
I want to add a third column which combines year and month and duplicate the rows from start date month to end date month as below on a different sheet. (The source sheet have many columns and rows).


1695737983530.png


Any help or advice will be appreciated.

Wikus
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hi wikus,

I was able to get this far...
Book1
ABC
1Start DateEnd DateYearMonth
211/18/20225/12/20242022M11
32022M12
42023M1
52023M2
62023M3
72023M4
82023M5
92023M6
102023M7
112023M8
122023M9
132023M10
142023M11
152023M12
162024M1
172024M2
182024M3
192024M4
202024M5
Sheet3
Cell Formulas
RangeFormula
C2:C20C2=DATE(YEAR($A$2),MONTH($A$2)+SEQUENCE(DATEDIF(A2,DATE(YEAR(B2),MONTH(B2),DAY(A2)),"m")+1,,0,1),1)
Dynamic array formulas.

Somehow I remembered the DATEDIF function from years ago...the function that doesn't show up when typing it.:biggrin:

Anyway, I am not good at stacking these functions if there when there more dates below those in A2:B2. There are many in here who are able to add to what I have done to make that happen...calling the pros to step in please 🙏

Hope that helps,

Doug
 
Upvote 0
Hi wikus,

I was able to get this far...
Book1
ABC
1Start DateEnd DateYearMonth
211/18/20225/12/20242022M11
32022M12
42023M1
52023M2
62023M3
72023M4
82023M5
92023M6
102023M7
112023M8
122023M9
132023M10
142023M11
152023M12
162024M1
172024M2
182024M3
192024M4
202024M5
Sheet3
Cell Formulas
RangeFormula
C2:C20C2=DATE(YEAR($A$2),MONTH($A$2)+SEQUENCE(DATEDIF(A2,DATE(YEAR(B2),MONTH(B2),DAY(A2)),"m")+1,,0,1),1)
Dynamic array formulas.

Somehow I remembered the DATEDIF function from years ago...the function that doesn't show up when typing it.:biggrin:

Anyway, I am not good at stacking these functions if there when there more dates below those in A2:B2. There are many in here who are able to add to what I have done to make that happen...calling the pros to step in please 🙏

Hope that helps,

Doug
Thanks Doug, this is a good start.
 
Upvote 0
Another option
Fluff.xlsm
ABC
1Start DateEnd DateYearMonth
212/09/202301/04/20242023M9
318/11/202212/05/20242023M10
42023M11
52023M12
62024M1
72024M2
82024M3
92024M4
102022M11
112022M12
122023M1
132023M2
142023M3
152023M4
162023M5
172023M6
182023M7
192023M8
202023M9
212023M10
222023M11
232023M12
242024M1
252024M2
262024M3
272024M4
282024M5
292024M6
30
Data
Cell Formulas
RangeFormula
C2:C29C2=LET(d,DATEDIF(EOMONTH(--A2:A3,-1),EOMONTH(--B2:B3,0),"m")+1,TOCOL(IF(SEQUENCE(,MAX(d))<=d,TEXT(DATE(YEAR(A2:A10),MONTH(A2:A10)+SEQUENCE(,MAX(d),0),1),"yyyy""M""m"),1/0),2))
Dynamic array formulas.
 
Upvote 1
Another option
Fluff.xlsm
ABC
1Start DateEnd DateYearMonth
212/09/202301/04/20242023M9
318/11/202212/05/20242023M10
42023M11
52023M12
62024M1
72024M2
82024M3
92024M4
102022M11
112022M12
122023M1
132023M2
142023M3
152023M4
162023M5
172023M6
182023M7
192023M8
202023M9
212023M10
222023M11
232023M12
242024M1
252024M2
262024M3
272024M4
282024M5
292024M6
30
Data
Cell Formulas
RangeFormula
C2:C29C2=LET(d,DATEDIF(EOMONTH(--A2:A3,-1),EOMONTH(--B2:B3,0),"m")+1,TOCOL(IF(SEQUENCE(,MAX(d))<=d,TEXT(DATE(YEAR(A2:A10),MONTH(A2:A10)+SEQUENCE(,MAX(d),0),1),"yyyy""M""m"),1/0),2))
Dynamic array formulas.
Thank you, much appreciated.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,417
Messages
6,124,791
Members
449,188
Latest member
Hoffk036

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