The revolutionary project management tool is here! Plan visually with a single glance and make sure your projects get done.
Sub test()
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
'Assume your value is in Column C
For i = 1 To LR
n = Cells(i, 3).Value
If n > 1 Then
Cells(i, 3).EntireRow.Select
Selection.Copy
For j = 1 To n - 1
Cells(i + 1, 3).EntireRow.Insert
Next
End If
Next i
End Sub
That way your data file will be properly prepared and you will get the outcome you want
Sub MergeRepeatingRecords()
Dim r As Integer
Dim wdDoc As Document
Dim n As Integer
Dim iLastRecord As Integer
Set wdDoc = ActiveDocument
With wdDoc.MailMerge
'establish last record number
.DataSource.ActiveRecord = wdLastDataSourceRecord
iLastRecord = .DataSource.ActiveRecord
.Destination = wdSendToNewDocument
'step through Datasource records
r = 0
Do Until r = iLastRecord
.DataSource.LastRecord = r
.DataSource.FirstRecord = r
For n = 1 To .DataSource.DataFields("RepeatNumber").Value
.Execute
Next n
r = r + 1
Loop
End With
End Sub
DIM j as long, n as long
n = Cells(i, 3).Value
was empty at one point, so not an integer.Sub test2()
Dim LR As Long
Dim r As Long
Dim c As Integer
Dim n As Integer
Dim j As Integer
LR = Range("A" & Rows.Count).End(xlUp).Row
'Assume your value is in Column J (10)
c = 10
For r = LR To 2 Step -1
n = Cells(r, c).Value
For j = 1 To n - 1
Cells(r, c).EntireRow.Copy
Cells(r, c).EntireRow.Insert xlShiftDown
Next
Next r
End Sub