Sub test()
Dim lRow As Long, i As Long, j As Long
lRow = Cells(Rows.Count, "A").End(xlUp).Row
With Application
.ScreenUpdating = False
For i = lRow To 2 Step -1
For j = 1 To Evaluate("Mod(" & Month(Cells(i, "B").Value) - Month(Cells(i, "A").Value) & ",12)")
Rows(i).Offset(1).EntireRow.Insert
Next
Next
.ScreenUpdating = True
End With
End Sub
Option Explicit
Sub InsertRows()
Dim LastRow As Long
Dim AddToRow As Long
Dim InsDiff As Integer
LastRow = Range("A" & Rows.Count).End(xlUp).Row 'calculate last row of column A
For AddToRow = LastRow To 2 Step -1 'from last to second row
InsDiff = DateDiff("m", Range("A" & AddToRow), Range("B" & AddToRow)) 'calculate difference by months
If InsDiff > 1 Then Range("A" & AddToRow + 1 & ":A" & AddToRow + InsDiff).EntireRow.Insert 'insert rows if difference
Next AddToRow
End Sub
Thank you very much for the reply.See if you can get this macro to work on your project (paste it in a standard or in the sheet's module):VBA Code:Option Explicit Sub InsertRows() Dim LastRow As Long Dim AddToRow As Long Dim InsDiff As Integer LastRow = Range("A" & Rows.Count).End(xlUp).Row 'calculate last row of column A For AddToRow = LastRow To 2 Step -1 'from last to second row InsDiff = DateDiff("m", Range("A" & AddToRow), Range("B" & AddToRow)) 'calculate difference by months If InsDiff > 1 Then Range("A" & AddToRow + 1 & ":A" & AddToRow + InsDiff).EntireRow.Insert 'insert rows if difference Next AddToRow End Sub
Hi Rollis,Thank you very much for the reply.
Will do, thank you.In truth, it seems to me that it is actually a different request from the title of this thread so in these cases, in order to have even a minimum of visibility in the Forum, I suggest starting a new thread with a new appropriate title.