Can't get Rows to delete in macro

  • Thread starter Thread starter Goobies
  • Start date Start date
G

Goobies

I have the following code which compiles and runs; however, it isn'
deleting rows as it should be. Basically I want the macro to chec
each row of Column O and if that value is < 3301, delete the entire ro
and shift the cels up.

The code is:

For i = 2 To 2000
If ActiveWorkbook.Worksheets(1).Cells(i, "O").Value <> "" Then
If ActiveWorkbook.Worksheets(1).Cells(i, "O").Value < 330
Then
Rows(i).Delete Shift:=xlUp
End If
End If
Next

Just to make sure the loop is functioning properly I changed the delet
line to

With Row(i).Interior
.ColorIndex = 6
.Pattern = xlSolid
End With

This made every row with the value less than 3301 highlighted yellow s
the loop functions fine. Just the deleteing part of it isn't..
 
You need to delete from bottom up ......

For i = 2000 To 2 Step -1


HTH
 

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