PDA

View Full Version : Solved: Repeat cells N Times



justdream
02-21-2013, 06:33 AM
Dears,

Could you please support creating Macro that repeat each cell N times "above each other"

Sample:

Artik
02-21-2013, 08:47 AM
Sub AAA()
Dim LastRow As Long
Dim i As Long
Dim N As Integer
Dim CalcMode As XlCalculation

With Application
.ScreenUpdating = False
.EnableEvents = False
CalcMode = .Calculation
.Calculation = xlCalculationManual
End With

LastRow = Cells(Rows.Count, "A").End(xlUp).Row

For i = LastRow To 1 Step -1
N = 0
If IsNumeric(Cells(i, "B")) Then
N = Cells(i, "B").Value
If N > 0 Then
Rows(i & ":" & i + N - 2).Insert Shift:=xlDown
Cells(i + N - 1, "A").Resize(, 2).Copy
Cells(i, "A").Resize(N).PasteSpecial
End If
End If
Next i

Application.CutCopyMode = False
Cells(i + 1, "A").Select

With Application
.EnableEvents = True
.Calculation = CalcMode
End With
End Sub

Artik

snb
02-21-2013, 09:05 AM
Do you need help or a solution ?