

Shade entire rows based on duplicate values in one column.
#Excel find duplicates in multiple rows how to#
How to find N th and subsequent duplicate records.How to highlight duplicates in a range (multiple columns).How to highlight duplicates in Excel except 1 st instances.Highlighting duplicates in Excel with 1 st occurrences (built-in rule).These techniques work in all versions of Excel 365, Excel 2019, Excel 2016, Excel 2013, Excel 2010 and lower. The biggest advantage of this method is that it not only shows you the existing dupes, but detects and colors new duplicates as you input, edit or overwrite your data.įurther on in this tutorial, you will find a number of ways to highlight duplicate records depending on your specific task. The fastest way to find and highlight duplicates in Excel is using conditional formatting. Undoubtedly, the duplicate formulas are very useful, but highlighting duplicate entries with a defined color could make data analysis even easier. Last week, we explored different ways to identify duplicates in Excel. Also, you will see how to highlight duplicates with different colors using a specialized tool. We are going to have a close look at different methods to shade duplicate cells, entire rows, or consecutive dupes using conditional formatting. Read also: What is VBA Range.In this tutorial, you will learn how to show duplicates in Excel. So, the topmost unique row will remain as seen below: Unlike example 1, in example 2, we will delete only the rows from the outer for loop counter, that is, starting from the bottom. Range("A" & amp rowNo).EntireRow.Delete Delete the current rowNo and proceed to next row If Range("C" & amp compRow) = Range("C" & amp rowNo) Then If Range("B" & amp compRow) = Range("B" & amp rowNo) Then If Range("A" & amp compRow) = Range("A" & amp rowNo) Then This is because the row counter will get messed up after deleting a row when you start from the top. For deleting rows, you should always start from the last row and move upwards.
#Excel find duplicates in multiple rows code#
If you want to remove the duplicate rows, you need to change the code a bit. Thus, you can easily adapt the code for any number of columns. If there is a match, the next column is checked. Range("A" & amp amp amp amp amp amp amp rowNo & amp amp amp amp amp amp amp ":C" & amp amp amp amp amp amp amp rowNo).Interior.Color = vbYellowĪs you can see, first column A of a row is compared with column A of each remaining rows. Range("A" & amp amp amp amp amp amp amp compRow & amp amp amp amp amp amp amp ":C" & amp amp amp amp amp amp amp compRow).Interior.Color = vbYellow If Range("C" & amp amp amp amp amp amp amp compRow) = Range("C" & amp amp amp amp amp amp amp rowNo) Then 'If a match is found in Columns A and B, check correspoding values of column C

If Range("B" & amp amp amp amp amp amp amp compRow) = Range("B" & amp amp amp amp amp amp amp rowNo) Then 'If a match is found in Column A, check correspoding values of column B If Range("A" & amp amp amp compRow) = Range("A" & amp amp amp amp amp amp amp rowNo) Then

'Check if a match is found in Column A for the current rowNo 'For each rowNo, loop through all the remaining rows Sub highlightDuplicateRows()ĭim lastRow As Integer, compRow As Integer, rowNo As Integer The comments in the code below will help you follow through the code. For this, we will be using two for loops – first one to loop through all the rows and second to find a match for the current row. For each row, you need to check if there is another row with the exact same data. Consider you have 3 columns of data with few duplicate rows as seen below:Īnd you need to highlight the rows that are not unique. As there is no direct way to achieve this, we need to loop through all the rows in the data. In this article we will look at how to find duplicate entries across columns using Excel VBA.
