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:
[TABLE="class: cms_table, width: 229"]
<tbody>[TR]
[TD="align: right"]3[/TD]
[TD]Sunday[/TD]
[TD]2/17/2019[/TD]
[/TR]
[TR]
[TD="align: right"]26[/TD]
[TD]Monday[/TD]
[TD]2/18/2019[/TD]
[/TR]
[TR]
[TD="align: right"]16[/TD]
[TD]Tuesday[/TD]
[TD]2/19/2019[/TD]
[/TR]
[TR]
[TD="align: right"]17[/TD]
[TD]Wednesday[/TD]
[TD]2/20/2019[/TD]
[/TR]
[TR]
[TD="align: right"]19[/TD]
[TD]Thursday[/TD]
[TD]2/21/2019[/TD]
[/TR]
[TR]
[TD="align: right"]16[/TD]
[TD]Friday[/TD]
[TD]2/22/2019[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD]Saturday[/TD]
[TD]2/23/2019[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Thanks for any insight you have,
Bill
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
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,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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