View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Philip Philip is offline
external usenet poster
 
Posts: 156
Default Simple For-Loop gives 1004 error using variable to EntireRow.Delet

Hi,

this is because the rows in Excel start at 1, but yout loop (that references
the rows) starts at 0

so try this:
For i = 1 To 200 Step 2
Sheet1.Rows(i).EntireRow.Delete
Next i

HTH

Philip


"EdMX" wrote:

Sorry I'm a real newbie to Excel and VB but here goes:
Why does this code give me an error in Excel?

Sub Eds1()
Dim i As Integer
For i = 0 To 200 Step 2
Sheet1.Rows(i).EntireRow.Delete
Next i
End Sub