ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VB to insert duplicate rows based on value in other row (https://www.excelbanter.com/excel-programming/446619-vbulletin-insert-duplicate-rows-based-value-other-row.html)

[email protected]

VB to insert duplicate rows based on value in other row
 
Hello all -

I would like something that automatically duplicates a pre-formatted row 11 based on the value in E7.

For example, if I enter "24" in E7, I would like Row 11 duplicated so it appears 24 times, beginning with Row 11. ROWS 1-10 have header and project information.

Any help would be greatly appreciated.

Auric__

VB to insert duplicate rows based on value in other row
 
bjclux wrote:

I would like something that automatically duplicates a pre-formatted row
11 based on the value in E7.

For example, if I enter "24" in E7, I would like Row 11 duplicated so it
appears 24 times, beginning with Row 11. ROWS 1-10 have header and
project information.


Try this:

Sub duplicateNtimes()
Dim v As Variant, L0 As Long
v = Cells(7, 5).Value
If IsNumeric(v) Then
Rows(11).Copy
For L0 = 2 To v
ActiveSheet.Paste Destination:=Cells(10 + L0, 1)
Next
Application.CutCopyMode = False
End If
End Sub

--
Tell 'em Large Marge sent ya!


All times are GMT +1. The time now is 08:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com