+ Reply to Thread
Results 1 to 10 of 10

Please check Row deletion code

  1. #1
    Registered User
    Join Date
    03-16-2013
    Location
    karachi
    MS-Off Ver
    Excel 2003
    Posts
    40

    Please check Row deletion code

    Dear Expert,
    I write an macro for the deletion of same data in a row just after the searching and thanks to this forum. Please anyone correct me because i found an error in the execution.Attachment is for your ref:

    Code::

    Sub del()
    Dim a As Range
    Dim b, c As Integer
    a = Cells(Row.Count, a).End(X1up).Row
    For b = 1 To a Step -1
    For c = 2 To a Step -1
    If Cells(b, a).Value = Cells(c, a).Value Then
    Cells(c, a).EntireRow.delete
    Next c
    Next a
    End Sub
    Attached Files Attached Files

  2. #2
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Please check Row deletion code

    Dim a As Long

    and

    a = Cells(Rows.Count, a).End(X1up).Row
    Gary's Student

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Please check Row deletion code

    Use indentation in your code

    Please Login or Register  to view this content.
    Last edited by AB33; 06-10-2013 at 08:36 AM.

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Please check Row deletion code

    Try this...

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Please check Row deletion code

    Use Excel's function (Remove duplicates). You do not need a code for this task.

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Please check Row deletion code

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    03-16-2013
    Location
    karachi
    MS-Off Ver
    Excel 2003
    Posts
    40

    Re: Please check Row deletion code

    Dear All Experts,
    Thanks alot.

    @AB33, as i am beginner, so i will do from VBA

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Please check Row deletion code

    "so i will do from VBA"
    Hence I have corrected your code. The reason for not seeing the error is because of lack of indentation. If you had indented the code, you would have spotted the error.

  9. #9
    Registered User
    Join Date
    03-16-2013
    Location
    karachi
    MS-Off Ver
    Excel 2003
    Posts
    40

    Re: Please check Row deletion code

    I found an error of "Type Mismatch" from the below code:

    Sub del()
    Dim a As Range
    Dim b, c As Integer
    a = Cells(Rows.Count, a).End(X1up).Row
    For b = 1 To a Step -1
    For c = 2 To a Step -1
    If Cells(b, a).Value = Cells(c, a).Value Then
    Cells(c, a).EntireRow.Delete
    End If
    Next c
    Next b
    End Sub

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Please check Row deletion code

    Please use code tags with your code

    Please Login or Register  to view this content.

+ 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