if any complete row is completely same with any other row in a sheet then delete the duplicate data

if any complete row  is completely same with any other row in a sheet then delete the duplicate data
see sheet2 for the result that I need
this highlighted colour is only for understanding purpose
i have to do this by vba
Avinash SinghAsked:
Who is Participating?
Subodh Tiwari (Neeraj)Connect With a Mentor Excel & VBA ExpertCommented:
Please give this a try...
Sub DeleteDuplicateRows()
Dim lr As Long, lc As Long, i As Long
Dim x, dict
Dim str As String
Dim delRng As Range

Application.ScreenUpdating = False
lr = Cells(Rows.Count, 1).End(xlUp).Row
Set dict = CreateObject("Scripting.Dictionary")

For i = 1 To lr
    lc = Cells(i, Columns.Count).End(xlToLeft).Column
    x = Range("A" & i, Cells(i, lc)).Value
    If IsArray(x) Then
        str = Join(Application.Index(x, 1, 0), ",")
        str = x
    End If
    If Not dict.exists(str) Then
        dict.Item(str) = ""
        If delRng Is Nothing Then
            Set delRng = Cells(i, 1)
            Set delRng = Union(delRng, Cells(i, 1))
        End If
    End If
Next i
If Not delRng Is Nothing Then delRng.EntireRow.Delete
Application.ScreenUpdating = True
End Sub

Open in new window

ShumsDistinguished Expert - 2017Commented:
Hi Avinash,

Try below quick VBA without loop:
Sub DelDup()
Dim Ws As Worksheet
Dim LRow As Long
Dim LCol As Integer
Set Ws = Worksheets("Sheet1")
LRow = Ws.UsedRange.Rows.Count
LCol = Ws.Cells.Find(What:="*", After:=Ws.Range("A1"), SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column + 1
Application.ScreenUpdating = False
With Ws.Range("A1:A" & LRow)
    .AdvancedFilter xlFilterInPlace, Unique:=True
    .SpecialCells(xlCellTypeVisible).Offset(0, LCol - 1).Value = 1
    On Error Resume Next
End With
Application.ScreenUpdating = True
End Sub

Open in new window

Kindly note you need to have header column to execute above VBA
Check in attached...
Avinash SinghAuthor Commented:
Thnx Neeraj sir for ur great support  and thnx alot for giving ur precious time to this post
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You're welcome Avinash!

Please remember to recognize the answers and queries posted other than the accepted answer also.
Experts devote their time in order to assist you and it's not fair when you don't respond to them properly.
Tell them politely why other solutions didn't work for you and why did you choose a specific answer as an accepted answer. That's a good habit and you will always get response of all the experts in your future questions. And if more than one answers work for you exactly as per your requirement, don't forget to split the points in that case.
Avinash SinghAuthor Commented:
Ok Neeraj sir in future i will not repeat this mistake again
Avinash SinghAuthor Commented:
Thnx shums sir for giving ur precious time to this post by mistakely i forgot to thnx u bcoz i just wake up in the morning and opened my pc and saw the solution actually i wasn't fresh that's why i forgot to thnx u
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Thanks Avinash!
All Courses

From novice to tech pro — start learning today.