I have a userform in which the user enters data. This data is then sent to a database sheet.
This is done through the following code:
How would i make particular entries unique?
For example maybe i would like the ModelNo to be unique. So only one entry in the database should have a particular Model Number.
This is done through the following code:
VBA Code:
Dim sh As Worksheet
Dim iRow As Long
Set sh = ThisWorkbook.Sheets("Database")
If frmForm.txtRowNumber.Value = "" Then
iRow = [Counta(Database!A:A)] + 1
Else
iRow = frmForm.txtRowNumber.Value
End If
With sh
'adding each row to database
.Cells(iRow, 1) = "=Row()-1" 'Dynamic Serial Number
.Cells(iRow, 2) = frmForm.ModelNo.Value
.Cells(iRow, 3) = frmForm.PartNo.Value
.Cells(iRow, 4) = frmForm.WorksOrderNo.Value
.Cells(iRow, 5) = frmForm.SerialNo.Value
.Cells(iRow, 6) = frmForm.MaterialNo.Value
.Cells(iRow, 7) = frmForm.SerialNumber.Value
.Cells(iRow, 8) = frmForm.txtType.Value
.Cells(iRow, 9) = frmForm.txtSize.Value
How would i make particular entries unique?
For example maybe i would like the ModelNo to be unique. So only one entry in the database should have a particular Model Number.