macros

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'd like to create a macro that deletes every other row. When I record the
macro it only deletes the cell I used for recording. How do I make the macro
so it runs on any cell?
 
ilastrow = Cells(Rows.Count,"A") .row
if iLastRow Mod 2 <> 0 then
iLastRow = iLastrow -1
End If
For i = ilastrowTo 1 Step 2
rows(i).delete
mext i
 
Hi khen1,

Try this:

Sub Test()
With ActiveSheet
For i = .Cells(.Rows.Count, "A"). _
End(xlUp).Row To 2 Step -2
.Rows(i).Delete
Next i
End With
End Sub


Regards,
KL
 

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