Solved

Excel

Posted on 2016-11-25
3
22 Views
Last Modified: 2016-11-25
Hello,
Find  a identical   row in the excel worksheet in vba .

Cheers
0
Comment
Question by:RIAS
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
Andy earned 500 total points
ID: 41901681
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
 

Author Closing Comment

by:RIAS
ID: 41901683
Cheers Andy!
0
 
LVL 6

Expert Comment

by:Andy
ID: 41901684
A pleasure!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now