OKay got it..have you tried looking at this code here?
isn't this much simpler ? let me demonstrate by giving you my workbook so u can take a look at it..Option Explicit Sub sbFindDuplicatesInColumn_C() 'Declaring the lastRow variable as Long to store the last row value in the Column1 Dim lastRow As Long 'matchFoundIndex is to store the match index values of the given value Dim matchFoundIndex As Long 'iCntr is to loop through all the records in the column 1 using For loop Dim iCntr As Long 'Finding the last row in the Column 1 lastRow = Range("A65000").End(xlUp).Row 'looping through the column1 For iCntr = 1 To lastRow 'checking if the cell is having any item, skipping if it is blank. If Cells(iCntr, 1) <> "" Then 'getting match index number for the value of the cell matchFoundIndex = WorksheetFunction.Match(Cells(iCntr, 1), Range("A1:A" & lastRow), 0) 'if the match index is not equals to current row number, then it is a duplicate value If iCntr <> matchFoundIndex Then 'Printing the label in the column B 'Cells(iCntr, 1).EntireRow.Delete Cells(iCntr, 1).Interior.Color = RGB(255, 20, 0) 'Cells(iCntr, 9) = "duplicate" End If End If Next End Sub 'Sub DeleteRowswithSpecificValue() 'Dim i As Variant 'For i = Range("A" & Rows.Count).End(xlUp).Row To 1 Step -1 'If Cells(i, 1).Value = "c:\test with spaces" Then 'Cells(i, 1).Interior.Color = RGB(255, 0, 0) 'Cells(i, 3).Interior.Color = RGB(0, 255, 0) 'Cells(i, 2).Interior.Color = RGB(0, 255, 255) 'End If 'Next i 'End Sub Sub Deleteit() Dim i As Variant For i = Range("A" & Rows.Count).End(xlUp).Row To 1 Step -1 If Cells(i, 1).Interior.Color = RGB(255, 20, 0) Then Cells(i, 1).EntireRow.Delete 'Cells(i, 1).Interior.Color = RGB(0, 255, 0) End If Next i End Sub





Reply With Quote