how do I create a macro to auto insert rows?

A

aashish

I have a 1000+ list and i want to enter a blank row after each entry that
does not equal the prior one. The repeated entries are not evenly spaced.
Can a macro look at a value, determine if it's equal to the prior, and if
not, insert a row?

thanks.
 
G

Gary''s Student

Try this:


Sub Macro1()
For i = 1 To 40
j = i + 1
If Not (Cells(i, 1) = Cells(j, 1)) Then
Rows(j).Select
Selection.Insert
i = i + 1
End If
Next
End Sub
 
Top