Problem with macro adding rows

Joined
Dec 17, 2007
Messages
3
Reaction score
0
I have written this macro. The information that I am working with has a title in column A. The name is supposed to repeat once so that there are two rows of information associated with the same name. This macro is supposed to fix that by adding a blank row below lines that only have one consecutive title name. I have another macro that copies the appropriate infomation into that row.

The Problem:
This macro works perfectly until it gets to a point where there are multiple "one-liners" in a row. Then all the rows that are inserted are done so under the first one in the series. I just need to make this macro to insert only under the one-liner so I do not have to go back and make corrections manually (which defeats the purpose of it).

Macro:
Sub ADDING_ROWS_TO_SINGLE_LINE_ROWS()
Dim Rng As Range
Application.ScreenUpdating = False
Columns("A:A").Insert
Set Rng = Range("A3:A9999")
With Rng
.FormulaR1C1 = "=IF(AND(R[-1]C[1]<>RC[1],R[-2]C[1]<>R[-1]C[1]),"""",1)"
.SpecialCells(xlCellTypeFormulas, 2).EntireRow.Insert Shift:=x1up
End With
Columns("A:A").Delete
Application.ScreenUpdating = True
End Sub


ALSO

Is there a better way to set the range so that it only worries about rows that contain information. This is really important for another macro that I have.
 

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

Back
Top