PDA

View Full Version : Solved: Insert an empty line between interval



marreco
08-26-2012, 08:47 AM
Hi.

I need to insert empty rows based on a criteria in cell 'A1'

example
is' A1 'is equal to 3 then will be inserted between the range three lines "A2: G10'
I tried this but not working:(
Sub Insert_Blank_Rows()

'Select last row in worksheet.
Selection.End(xlDown).Select

Do Until ActiveCell.Row = Range("A1").Value
'Insert blank row.
ActiveCell.EntireRow.insert shift:=xlDown
'Move up one row.
ActiveCell.Offset(-1, 0).Select
Loop

End Sub

Bob Phillips
08-26-2012, 09:42 AM
Sub Insert_Blank_Rows()
Dim lastrow As Long
Dim i As Long

Application.ScreenUpdating = False

With ActiveSheet

lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = lastrow To 1 Step -1

If IsNumeric(.Cells(i, "A").Value) Then

If .Cells(i, "A").Value > 0 Then

.Cells(i + 1, "A").Resize(.Cells(i, "A").Value, 7).Insert shift:=xlDown
End If
End If
Next i
End With

Application.ScreenUpdating = True
End Sub

marreco
08-26-2012, 09:52 AM
Hi.

Was Great!!!:yes

Thank you!!