View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Toppers Toppers is offline
external usenet poster
 
Posts: 4,339
Default Loop through records

Erin,
Try this (on some test data first!)

Sub InsertRows()

Dim lastrow as long, r as long

lastrow = Cells(Rows.Count, "A").End(xlUp).Row

For r = lastrow To 2 Step -1

If Cells(r, 1) < Cells(r - 1, 1) Then
Cells(r, 1).Insert shift:=xlDown
End If

Next r

End Sub

HTH

" wrote:

Hello everyone,
i am new to vba and excel. In column A i have 47000 rows, i want to
loop through this column and if cell1 does not equal cell2 i want to
add a row between cell1 and cell2. I cannot figure out how to do this..
can anyone help me please??/
Thanks,
Erin