Dear Team,
I have a vba userform which enters data into multiple sheets. For two comboboxes, there can be "X" combinations like as follows:
Column B Column C
John Red
John Black
Michael Red
Michael Black
I want to prevent duplicate entries into columns. Currently I am using following code but it doesn't allow me to add multiple combinations. e.g. It won't allow me to add "Michael Red" if I have added "John Red" earlier in sheet.
With ws
If Not (WorksheetFunction.CountIf(ws.Range("D:D"), ComboBox6.Value) > 0 And WorksheetFunction.CountIf(ws.Range("E:E"), ComboBox3.Value) > 0) Then
.Cells(emptyRow, 1).Value = ComboBox7.Value
.Cells(emptyRow, 2).Value = ComboBox8.Value
.Cells(emptyRow, 3).Value = ComboBox9.Value
.Cells(emptyRow, 4).Value = ComboBox6.Value
.Cells(emptyRow, 5).Value = ComboBox3.Value
.Cells(emptyRow, 6).Value = TextBox1.Value
Response3 = MsgBox("Do you want to add more data", vbYesNo)
If Response3 = vbYes Then
ComboBox3.Value = Null
ComboBox6.Value = Null
TextBox1.Value = Null
Else
End If
Else
MsgBox ("Warning:Duplicate Entries Found. Please edit existing entries")
End If
End With
End If
Please help for this query.
Bookmarks