Split Rows by Condition

tejapowerbi

New Member
Joined
Nov 30, 2018
Messages
19
Happy Friday Everyone,
I have a below scenarios where I want to split rows (not column) based on condition. If the Month column has <12 then only rows required but if it is 12 month then 2 Rows required,15 month then one row with 12 months and one row with 3 months and if it is 24 months then split two rows in 12 months and 36 months then split 3 rows in 12 months and so on..Can any provide any suggestion?

[TABLE="width: 225"]
<tbody>[TR]
[TD]start
[/TD]
[TD]end
[/TD]
[TD]months
[/TD]
[/TR]
[TR]
[TD]1/1/2014
[/TD]
[TD]1/1/2015
[/TD]
[TD]12
[/TD]
[/TR]
[TR]
[TD]1/1/2014
[/TD]
[TD]1/1/2016
[/TD]
[TD]24
[/TD]
[/TR]
[TR]
[TD]1/1/2014
[/TD]
[TD]1/1/2017
[/TD]
[TD]36
[/TD]
[/TR]
[TR]
[TD]1/1/2014
[/TD]
[TD]1/1/2015
[/TD]
[TD]7
[/TD]
[/TR]
[TR]
[TD]1/1/2014
[/TD]
[TD]1/3/2015
[/TD]
[TD]15
[/TD]
[/TR]
</tbody>[/TABLE]

[TABLE="width: 225"]
<tbody>[TR]
[TD]start
[/TD]
[TD]end
[/TD]
[TD]months
[/TD]
[/TR]
[TR]
[TD]1/1/2014
[/TD]
[TD]1/1/2015
[/TD]
[TD]12
[/TD]
[/TR]
[TR]
[TD]1/1/2014
[/TD]
[TD]1/1/2015
[/TD]
[TD]12
[/TD]
[/TR]
[TR]
[TD]1/1/2014
[/TD]
[TD]1/1/2015
[/TD]
[TD]24
[/TD]
[/TR]
[TR]
[TD]2/1/2015
[/TD]
[TD]31/1/2016
[/TD]
[TD]24
[/TD]
[/TR]
[TR]
[TD]1/1/2014
[/TD]
[TD]1/1/2015
[/TD]
[TD]36
[/TD]
[/TR]
[TR]
[TD]2/1/2015
[/TD]
[TD]1/1/2016
[/TD]
[TD]36
[/TD]
[/TR]
[TR]
[TD]2/1/2016
[/TD]
[TD]31/1/2017
[/TD]
[TD]36
[/TD]
[/TR]
[TR]
[TD]1/1/2014
[/TD]
[TD]1/1/2015
[/TD]
[TD]7
[/TD]
[/TR]
[TR]
[TD]1/1/2014
[/TD]
[TD]1/1/2015
[/TD]
[TD]15
[/TD]
[/TR]
[TR]
[TD]2/1/2015
[/TD]
[TD]1/3/2015
[/TD]
[TD]15
[/TD]
[/TR]
</tbody>[/TABLE]
 
Hi Peter,
I just want to share a good news with you.
Finally your suggested code is in production and it is splits more than 900,000 rows successfully without a single error.
[FONT=q_serif]
Thank you so much for your great Help.


[/FONT]
 
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,226,195
Messages
6,189,571
Members
453,554
Latest member
Kate_

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