Insert rows based on condition

wilhelm

New Member
Joined
Mar 26, 2013
Messages
16
Hello, I can't find a solution for my problem. I need a macro to insert new rows and copy values from columns in the row ahead to the new lines. Column A is company name and Column C is text that belong to the company. Column B is number of periods, and I need it to be until 5 periods for all cases. It hasn't to start with 1 but to be up to 5.

Here is what is look like:
A1: X B1: 1 C1: abc
A2: X B2: 2 C2: abc
A3: X B3: 3 C3: abc
A4: Y B4: 2 C4: ced
A5: Y B5: 3 C5: ced
A6: Y B6: 4 C6: ced
A7: Z B7: 4 C7: efg
A8: Z B8: 5 C8: efg

And here is how I want it

A1: X B1: 1 C1: abc
A2: X B2: 2 C2: abc
A3: X B3: 3 C3: abc
Insert 2 rows:
A4: X B4: 4 C4: abc
A5: X B5: 5 C5: abc

A6: Y B6: 2 C6: ced
A7: Y B7: 3 C7: ced
A8: Y B8: 4 C8: ced
Insert 1 row:
A9: Y B9: 5 C9: ced

A10: Z B10: 4 C10: efg
A11: Z B11: 5 C11: efg
Insert no row


Thanks a lot!
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,215,700
Messages
6,126,283
Members
449,308
Latest member
VerifiedBleachersAttendee

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