How To Prevent / Restriction Duplicate Entry in Excel

VBA Code;


Private Sub Worksheet_Change(ByVal Target As Range)

    With Target

        If (.Column <> 2 And .Column <> 5) Or .Cells.Count > 1 Then Exit Sub


        If WorksheetFunction.CountIfs(Columns(.Column), .Value) > 1 Then

            Application.DisplayAlerts = False

            .ClearContents

            Application.DisplayAlerts = True

            MsgBox "Duplicate value!"

        End If


    End With

End Sub


Comments

Popular posts from this blog

Physical properties of Liquid

Characteristics and Limitations of computer:

1.4 Bent Axis Piston Pump