Consulting

Results 1 to 3 of 3

Thread: Solved: Repeat cells N Times

  1. #1

    Solved: Repeat cells N Times

    Dears,

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

    Sample:
    Attached Files Attached Files

  2. #2
    VBAX Mentor
    Joined
    Dec 2008
    Posts
    404
    Location
    [VBA]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[/VBA]

    Artik

  3. #3
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    Do you need help or a solution ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •