Can someone kindly help me out with this.
Below is a VBA code to cut and insert an entire row one row down on event a condition is statisfied and all rows are re-calculated with a VBA macro.
But it continuous as an endless loop when successive rows below also satisfy the condition, so the code must be improved to carry over these rows also.
The error starts at Row Number 87 in the attached sample data.
Below is a VBA code to cut and insert an entire row one row down on event a condition is statisfied and all rows are re-calculated with a VBA macro.
But it continuous as an endless loop when successive rows below also satisfy the condition, so the code must be improved to carry over these rows also.
The error starts at Row Number 87 in the attached sample data.
Code:
Sub cutentirerowInsert2rowsdown()
Dim rw As Long
With ActiveWorkbook.ActiveSheet
LastRow = .UsedRange.Rows.Count
For rw = 4 To LastRow
.Cells(rw, 5).Select
If .Cells(rw, 5) < .Cells(rw, 11) Then 'If Start date less than Not Before date
Do Until .Cells(rw, 5) >= .Cells(rw, 11)
.Cells(rw, 5).EntireRow.Select 'Select entire row
Selection.Cut
.Cells(rw + 2, 5).EntireRow.Select
Selection.Insert Shift:=xlDo
Loop
End If
Copy_formula_from_rowNumber3_paste_up_to_last_row
Next rw
End With
End Sub