Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro to add a blank row when a difference between rows is found
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. |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Hiding blank rows using a macro | Excel Discussion (Misc queries) | |||
Macro Help- Inserting Blank Rows | Excel Discussion (Misc queries) | |||
Sort Macro to Exclude Blank Rows? | Excel Worksheet Functions | |||
Delete blank rows Macro | Excel Discussion (Misc queries) | |||
Inserting Blank Rows Macro? | Excel Worksheet Functions |