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

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Hi & welcome to MrExcel.
How about
Code:
Sub Billman101()
   Dim i As Long, Qty As Long
   
   For i = Range("A" & Rows.Count).End(xlUp).Row To 3 Step -3
      Rows(i + 2).Resize(Cells(i, 1)).Insert
   Next i
End Sub
 
Upvote 0
Thanks Fluff,

This seems to work but once it runs it returns an error. When I debug the following is highlighted:

Rows(i + 2).Resize(Cells(i, 1)).Insert

Thanks.
 
Upvote 0
Do you have numbers in every cell from A3 to the end of the column?
 
Upvote 0
Hi Fluff,

Thanks for help.

I've pasted a portion of my sheet below:

Component Asset Group Description (Level 7)WO NumberWO Status
2Sunday2/17/2019
26Monday2/18/2019
16Tuesday2/19/2019
17Wednesday2/20/2019
19Thursday2/21/2019
16Friday2/22/2019
2Saturday2/23/2019
<colgroup><col width="41" style="width: 31pt; mso-width-source: userset; mso-width-alt: 1499;"> <col width="107" style="width: 80pt; mso-width-source: userset; mso-width-alt: 3913;"> <col width="92" style="width: 69pt; mso-width-source: userset; mso-width-alt: 3364;"> <col width="87" style="width: 65pt; mso-width-source: userset; mso-width-alt: 3181;"> <tbody> </tbody>

What I need to have done is add space based on what's in col. A cells. Then paste in this space data from either an external file or within a tab in this spreadsheet.

The space needed to paste data from Col. A to L.

Many thanks,
 
Upvote 0
Could you please answer my question? ;)
 
Upvote 0
Oops, I should have said
Do you have numbers in every 3rd cell from A3 to the end of the column?
I ask because the code I supplied works for the data you posted.
 
Upvote 0
If you run this
Code:
Sub chk()
   MsgBox Range("A" & Rows.Count).End(xlUp).Row
End Sub
What does the Msgbox say?
 
Upvote 0

Forum statistics

Threads
1,213,567
Messages
6,114,342
Members
448,570
Latest member
rik81h

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