Macro to add a blank row when a difference between rows is found
The following macro will insert a blank row above the current row if the
difference between the cell in Col A in the row and the cell above it is
greater than 1
Sub AddRow()
ColumntoCheck = "A"
For i = Cells(Rows.Count, ColumntoCheck).End(xlUp).Row To 2 Step -1
If ((Cells(i, ColumntoCheck) - Cells(i - 1, ColumntoCheck)) 1) Then
Cells(i, "A").EntireRow.Insert
' Cells(i, ColumntoCheck) = Cells(i - 1, ColumntoCheck) + 1
End If
Next i
End Sub
"Aus-JN" wrote:
Hi All,
I would like to write a macro which selects a series of rows, sorts them by
a particular column and then adds a row whenever a difference bewteen the
rows for that particular column are found.
I can write the macrow which does the sorting but am struggling with adding
the line. I have googled this and have found many methods but unfortunately
I don't understand them enough to make them work for me - don't know which
variables I need to change etc.
|