Duplicate Entries

DanSMT

New Member
Joined
Sep 13, 2019
Messages
11
Hi again.

I would like to prevent duplicate entries to be entered into a spreadsheet when attempting to add with a error message saying "Duplicate Entry".

VBA Script below;

Code:
Private Sub ScanTB_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
    Dim LastRowFilled As Long
    Dim DataArray(1 To 4) As String
    Dim i As Integer
    Dim a As Integer, blnFound As Boolean
    Dim strNewName As String
    Dim ws As Worksheet
    Dim boolFound As Boolean
        strNewName = WOTB.Value
    For Each ws In Worksheets
         If ws.Name Like strNewName Then boolFound = True: Exit For
          Next
              If boolFound = True Then
                Sheets(strNewName).Select
                    Else
                       Sheets.Add.Name = strNewName
              End If
                 Cells(1, 5).Select
                 ActiveCell.Value = "=COUNTA((A:A)-1)"
                 Cells(1, 1).Select
                 ActiveCell.Value = "Carton Serial #"
                 Cells(1, 2).Select
                 ActiveCell.Value = "PCB Serial #"
                 Cells(1, 3).Select
                 ActiveCell.Value = "Employee #"
                 Columns("A:B").ColumnWidth = 30
                 Columns("C").ColumnWidth = 11
                 TextBox1.Font.Size = 28
                 TextBox1.Value = ActiveSheet.Range("E1").Value + 1
                    If Me.ScanTB = "" Then
                        Me.ScanTB.SetFocus
                            Else
                                Cells(Rows.Count, 1).End(xlUp).Offset(1).Value = ScanTB.Text
                                Cells(Rows.Count, 2).End(xlUp).Offset(1).Value = Scan2TB.Text
                                Cells(Rows.Count, 3).End(xlUp).Offset(1).Value = EMP.Text
                                Me.Scan2TB = ""
                                Me.ScanTB = ""
                                Cancel = True
                    End If
 End Sub
 
Last edited by a moderator:

Forum statistics

Threads
1,082,138
Messages
5,363,351
Members
400,729
Latest member
Lisa McConachy

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top