View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 113
Default Code and thanks for/to Tom and Frank

Hello again:

Thanks again guys but is not working:

So I have a big file; here are just few rows...

1 1 OK
2 2 OK
3 4 NO
2 2 OK
5 6 NO
******************

The code taht I would need is to search for no and when is
found to insert a row above

Thanks again and I am still testing those codes you gave
me but does not produce any result?

Sub InsertRowBeforeNo()
Dim rng as Range, i as Long
set rng = cells(rows.count,3).End(xlup)
for i = rng.row to 2 step -1
if Ucase(cells(rng.row,3).Value) = "NO" then
cells(rng.row,3).EntireRow.Insert
end if
Next
End Sub

Sub insert_rows()
Dim lastrow As Long
Dim row_index As Long

lastrow = ActiveSheet.Cells(Rows.count, "C").End(xlUp).row
For row_index = lastrow - 1 To 1 Step -1
If Cells(row_index+1, "C").Value ="No" Then
Cells(row_index + 1, "C").EntireRow.Insert
(xlShiftDown)
End If
Next
End Sub

Regards,

Dan