Inserting Row(s) based on cell Value on same sheet

Billman101

New Member
Joined
Feb 14, 2019
Messages
9
Hello,

First time post/reply. I'm a pro at recording macros
:wink: but not so much on writing them. I'm trying to insert Row(s) based on cell value(s) that reside within my sheet.

Cell A3 has a value of N = 3 and I'd like to insert N rows at row 5 (two rows lower than 3). Then
at Cell A6 which has a value of N = 26 I'd like to insert N rows at row 8 (again two rows lower) and so on as depicted below:
3Sunday2/17/2019
26Monday2/18/2019
16Tuesday2/19/2019
17Wednesday2/20/2019
19Thursday2/21/2019
16Friday2/22/2019
2Saturday2/23/2019

<tbody>
</tbody>

Thanks for any insight you have,
Bill
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
If you only have data to day 7, I would expect the Msgbox to have said 21, not 42.
Which means you have data of some sort in those extra rows of col A
 
Upvote 0
Ok I see where you'd get that. The first cell in Col. A that has data is at row 24 so this would put the last cell at row 42.

Bill
 
Upvote 0
In that case try
Code:
Sub Billman101()
   Dim i As Long, Qty As Long
   
   For i = Range("A" & Rows.Count).End(xlUp).Row To [COLOR=#ff0000]24[/COLOR] Step -3
      Rows(i + 2).Resize(Cells(i, 1)).Insert
   Next i
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,842
Messages
6,127,230
Members
449,371
Latest member
strawberrish

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