• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Highlight Duplicate Records using Vba

Hello Friends,

I need some help regarding find duplicates from column F and rename column CF as "Yes" and "No" if there are any duplicate records in F.

Appreciate your help here.

Attached sheet for your reference.

upload_2018-12-25_16-1-9.png
 

Attachments

  • Duplicates.xls
    29 KB · Views: 2
Hi Vltem,

A small change , I wanted to run this on the sheet name called "KPI".
so can we change the

With ActiveSheet

to

With Sheets("KPI").Select

upload_2018-12-25_17-0-46.png

----------------------------------------------------------------------------


Code:
Sub Do_It()
    Application.ScreenUpdating = False
    With ActiveSheet
        f_max = .Cells(.Rows.Count, "F").End(xlUp).Row
        For f = 2 To f_max
            chk_f = .Cells(f, 6)
            ff = WorksheetFunction.CountIf(.Range("F2:F" & f_max), chk_f)
            bg = xlNone
            msg = "No"
            If ff > 1 Then
                bg = 15
                msg = "Yes"
            End If
            .Cells(f, 6).Interior.ColorIndex = bg
            .Range("CF" & f) = msg
        Next f
        .Range("F1").Select
    End With
    Application.ScreenUpdating = True
End Sub
 
Last edited by a moderator:
Dinesh_Excel
If You would like, that it's possible to use ONLY with 'KPI'-sheet then Okay.
use
Code:
with Sheets("KPI")
Original code works with 'any sheet', which is active, then You run that macro.
 
Back
Top