+ Reply to Thread
Results 1 to 3 of 3

macros

  1. #1
    khen1
    Guest

    macros

    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?

  2. #2
    Bob Phillips
    Guest

    Re: macros

    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

    --
    HTH

    Bob Phillips

    "khen1" <[email protected]> wrote in message
    news:[email protected]...
    > 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?




  3. #3
    KL
    Guest

    Re: macros

    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


    "khen1" <[email protected]> wrote in message
    news:[email protected]...
    > 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?




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1