Leaving a blank row

R

rumkus

Sheet 1, first 4 columns have values something like

1,a,b,c
1,a,b,c
1,a,b,c
2,a,b,c
3,a,b,c
3,a,b,c

On report -sheet 2 - I'like to have a blank row between each
different value on column A. Like below

3 rows for 1
1 blank row
1 row for 2
1 blank row
2 rows for 3

I've had no difficulty coding my report so far. But leaving these
blank rows I couldn't manage.
Any helping code snippets will be really appreciated. Thank you.
 
G

Gord Dibben

Sub InsertRow_At_Change()
'Sandy Mann July 1st, 2007
Dim LastRow As Long
Dim X As Long
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
Application.ScreenUpdating = False

For X = LastRow To 3 Step -1
If Cells(X, 1).Value <> Cells(X - 1, 1).Value Then
If Cells(X, 1).Value <> "" Then
If Cells(X - 1, 1).Value <> "" Then
Cells(X, 1).entirerow.Insert Shift:=xlDown
End If
End If
End If
Next X
Application.ScreenUpdating = True
End Sub


Gord Dibben MS Excel MVP
 
R

rumkus

Sub InsertRow_At_Change()
'Sandy Mann July 1st, 2007
    Dim LastRow As Long
    Dim X As Long
    LastRow = Cells(Rows.Count, 1).End(xlUp).Row
    Application.ScreenUpdating = False

    For X = LastRow To 3 Step -1
        If Cells(X, 1).Value <> Cells(X - 1, 1).Value Then
            If Cells(X, 1).Value <> "" Then
                If Cells(X - 1, 1).Value <> "" Then
                    Cells(X, 1).entirerow.Insert Shift:=xlDown
                End If
            End If
        End If
    Next X
    Application.ScreenUpdating = True
End Sub

Gord Dibben  MS Excel MVP





- Show quoted text -

Gord, thank you so much.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top