+ Reply to Thread
Results 1 to 4 of 4

Macro for deleting every second Row of Data

  1. #1
    Tufail
    Guest

    Macro for deleting every second Row of Data

    hello
    i am trying to use this macro for delete from my data every second ROW , but
    couldn't use there is some error plz help me.
    thanks in advance.

    Sub abc()
    Dim frow As Long, lrow As Long
    Dim i As Long
    frow = Selection.Row
    lrow = Selection.Rows(Selection.Rows.Count).Row
    For i = lrow To frow Step -2
    Selection.Rows(A).Delete
    Shift:=B:C
    lShiftUp
    Next

    End Sub

  2. #2
    Forum Contributor
    Join Date
    03-24-2004
    Location
    Edam Netherlands
    Posts
    181
    Sub abc()

    Dim frow As Long, lrow As Long
    Dim i As Long

    frow = Selection.Row
    lrow = Selection.Rows(Selection.Rows.Count).Row

    For i = lrow To frow Step -2

    Rows(i).Delete

    Next

    End Sub

  3. #3
    Norman Jones
    Guest

    Re: Macro for deleting every second Row of Data

    Hi Tufail,

    It is not clear from your code anf question whether your intention is to:

    - delete every second column A cell in the selection

    or to

    - delete every second row in the selection.

    In the first case try:

    '=============>>
    Public Sub abc()
    Dim frow As Long, lrow As Long
    Dim i As Long

    frow = Selection.Row
    lrow = Selection.Rows(Selection.Rows.Count).Row
    For i = lrow To frow Step -2
    Cells(i, "A").Delete Shift:=xlShiftUp
    Next
    End Sub
    '<<=============

    in the second case, try instead:

    '=============>>
    Public Sub abc2()
    Dim frow As Long, lrow As Long
    Dim i As Long

    frow = Selection.Row
    lrow = Selection.Rows(Selection.Rows.Count).Row
    For i = lrow To frow Step -2
    Rows(i).Delete Shift:=xlShiftUp
    Next
    End Sub
    '<<=============

    If your intention is not met by eitherof these suggestions, perhaps you
    could endeavour to restate your requirements.


    ---
    Regards,
    Norman



    "Tufail" <[email protected]> wrote in message
    news:[email protected]...
    > hello
    > i am trying to use this macro for delete from my data every second ROW ,
    > but
    > couldn't use there is some error plz help me.
    > thanks in advance.
    >
    > Sub abc()
    > Dim frow As Long, lrow As Long
    > Dim i As Long
    > frow = Selection.Row
    > lrow = Selection.Rows(Selection.Rows.Count).Row
    > For i = lrow To frow Step -2
    > Selection.Rows(A).Delete
    > Shift:=B:C
    > lShiftUp
    > Next
    >
    > End Sub




  4. #4
    Bob Phillips
    Guest

    Re: Macro for deleting every second Row of Data

    Sub abc()
    Dim frow As Long, lrow As Long
    Dim i As Long
    frow = Selection.Row
    lrow = Selection.Rows(Selection.Rows.Count).Row
    For i = lrow To frow Step -2
    Rows(i).Delete
    Next

    End Sub


    --
    HTH

    Bob Phillips

    (replace somewhere in email address with gmail if mailing direct)

    "Tufail" <[email protected]> wrote in message
    news:[email protected]...
    > hello
    > i am trying to use this macro for delete from my data every second ROW ,

    but
    > couldn't use there is some error plz help me.
    > thanks in advance.
    >
    > Sub abc()
    > Dim frow As Long, lrow As Long
    > Dim i As Long
    > frow = Selection.Row
    > lrow = Selection.Rows(Selection.Rows.Count).Row
    > For i = lrow To frow Step -2
    > Selection.Rows(A).Delete
    > Shift:=B:C
    > lShiftUp
    > Next
    >
    > End Sub




+ 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