Excel - Repeat rows a specified number of times
Solved/Closed
Related:
- Excel repeat row n times formula
- Position formula in excel ✓ - Office Software Forum
- Date formula in excel dd/mm/yyyy - Guide
- How to calculate position (1st,2nd,3rd) in excel....? - Excel Forum
- Calculation of positions in excel ✓ - Excel Forum
- Formulas for 1st and 2nd position in class - Office Software Forum
1 response
Solved
http://www.mrexcel.com/forum/excel-questions/860196-copy-values-column-insert-8-times.html
Sub CopyData()
Dim lRow As Long
Dim RepeatFactor As Variant
Dim Num As Integer
Num = InputBox("How many Times")
lRow = 1
Do While (Cells(lRow, "A") <> "")
RepeatFactor = Num 'Cells(lRow, "B")
If ((RepeatFactor > 1) And IsNumeric(RepeatFactor)) Then
Range(Cells(lRow, "A"), Cells(lRow, "B")).Copy
Range(Cells(lRow + 1, "A"), Cells(lRow + RepeatFactor - 1, "B")).Select
Selection.Insert Shift:=xlDown
lRow = lRow + RepeatFactor - 1
End If
lRow = lRow + 1
Loop
Application.CutCopyMode = False
Range("A1").Select
End Sub
http://www.mrexcel.com/forum/excel-questions/860196-copy-values-column-insert-8-times.html
Sub CopyData()
Dim lRow As Long
Dim RepeatFactor As Variant
Dim Num As Integer
Num = InputBox("How many Times")
lRow = 1
Do While (Cells(lRow, "A") <> "")
RepeatFactor = Num 'Cells(lRow, "B")
If ((RepeatFactor > 1) And IsNumeric(RepeatFactor)) Then
Range(Cells(lRow, "A"), Cells(lRow, "B")).Copy
Range(Cells(lRow + 1, "A"), Cells(lRow + RepeatFactor - 1, "B")).Select
Selection.Insert Shift:=xlDown
lRow = lRow + RepeatFactor - 1
End If
lRow = lRow + 1
Loop
Application.CutCopyMode = False
Range("A1").Select
End Sub