Inserting Rows Macro -- please help!!

T

tratliff

I have a worksheet with @ 8000 rows.

The information in this worksheet is for @ 40 different customers bu
they are all together right now.

What I want is for a blank row to be inserted when the customer nam
changes.

For example:

if rows 3-39 are for ABC Co., Inc and rows 40-78 are for 123 Co., Inc

I want a blank row to be inserted between rows 39 and 40.

Any suggestions?
 
B

Bob Phillips

Sub InsertRows()
Dim cRows As Long
Dim i As Integer

For i = Cells(Rows.Count, "A").End(xlUp).Row To 2 Step -1
If Cells(i, "A") <> Cells(i + 1, "A") Then
Cells(i + 1, "A").EntireRow.Insert
End If
Next i
End Sub



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
L

Lynn A.

Just out of curiosity, why would you want to put blank rows in a
database?

Wouldn't it be better if you used an advanced filter on another sheet
to view each company when you want to see them.

If you have blank lines, everytime you enter new data you will have to
sort out the blank lines and then insert the blank rows again.

Lynn :)
 
T

tratliff

i need to insert the rows so I can do some formulas this workbook is no
used as a database, it is used to analyze data.

thanks
 
Top