• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 56
  • Last Modified:

Excel

Hello,
Find  a identical   row in the excel worksheet in vba .

Cheers
0
RIAS
Asked:
RIAS
  • 2
1 Solution
 
AndyIt ConsultantCommented:
Try something like this:

Option Explicit 
Sub HighDupes() 
    Dim ws1 As Worksheet 
    Dim Row1 As Range 
    Dim Col1 As Range 
    Dim NewStr1 As String 
     'Needs reference to Microsoft Scripting Runtime
    Dim MyDic As Dictionary 
    Set MyDic = New Dictionary 
    Set ws1 = ActiveWorkbook.Sheets(1) 
    Application.ScreenUpdating = False 
    For Each Row1 In ws1.UsedRange.Rows 
         'If rows are blank then skip
        If Application.CountA(ws1.Rows(Row1.Row)) > 0 Then 
            NewStr1 = "Sheet1" 
            For Each Col1 In ws1.UsedRange.Columns 
                NewStr1 = NewStr1 & "||" & ws1.Cells(Row1.Row, Col1.Column) 
            Next 
            If MyDic.exists(NewStr1) Then 
                 'Colour intra sheet duplicates in sheet 1 as blue
                ws1.Rows(Row1.Row).Interior.Color = vbBlue 
                ws1.Rows(MyDic(NewStr1)).Interior.Color = vbRed 
            Else 
                MyDic.Add NewStr1, Row1.Row 
            End If 
        End If 
    Next 
    Application.ScreenUpdating = True 
    Set MyDic = Nothing 
    Set ws1 = Nothing 
End Sub 

Open in new window


source: http://www.vbaexpress.com/forum/showthread.php?5000-Solved-how-to-highlight-duplicate-ROWS-in-excel
0
 
RIASAuthor Commented:
Cheers Andy!
0
 
AndyIt ConsultantCommented:
A pleasure!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now