• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Automatically add number of rows equal to number mentioned into cell

Hi,
Greetings!!
I have an excel file and in a column numbers(quantities) are mentioned. I want to insert equal number of rows after that particular cell. For ex-
In cell C5 15 is mentioned so 15 rows automatically get added
In cell C6 123 is mentioned so 123 rows automatically get added
Files is also attached.
I shall appreciate if Non VBA solution is provided
Thanks in advance!!
Regards
Neeraj Kumar Agarwal
 

Attachments

1] Not sure this is you wanted, but try take a look of the attachment.

2] I reduced the number of rows in column C5: C10 for testing purpose

3] In D5 formula copy down :

=LOOKUP(ROWS(A$1:A1),SUMIF(OFFSET(C$4,,,ROW($1:$7),),"<>")+1,B$5:B$10)&""

Regards
Bosco
 

Attachments

Hi,

Try the below vba snippet

Code:
Option Explicit

Sub test()

Dim LastRow As Long
Dim n As Long
Dim FirstRow as Interger
Dim AddRows As Integer
Dim ResultTab As Worksheet

FirstRow = 6

Set ResultTab = Sheets("REQUIREMENT") 'Change the worksheet name with your output tab

LastRow = ResultTab.Cells(Rows.Count, "C").Row '"C" signifies the column that contains number of rows to be inserted

For n = LastRow To FirstRow Step -1

  AddRows = Cells(n, 3).Value
 
  If AddRows > 0 Then
 
  ResultTab.Cells(n + 1, 3).Resize(AddRows, 1).EntireRow.Insert
 
  End If

Next n

End Sub
 
Back
Top