This might be some help
Private Sub cmbAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Dim rCl As Range
Set ws = Worksheets("Data")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for a Group
If Trim(UserForm1.ComboBoxgroup.Value) = "" Then
UserForm1.ComboBoxgroup.SetFocus
MsgBox "Please select an Inventory Group"
Exit Sub
End If
With ActiveSheet.UsedRange
Set rCl = .Find(Me.TextBoxserial.Value, LookIn:=xlValues)
'looks for serial& checks adjacent cell for ID
If Not rCl Is Nothing And IsEmpty(rCl.Offset(0, 1)) Then
MsgBox "Serial number " & Me.TextBoxserial.Value & "found. No ID# entered"
GoTo do_something
'check for ID selected on form
Else: Set rCl = .Find(Me.TextBoxid.Value, LookIn:=xlValues)
If Not rCl Is Nothing Then
MsgBox "Id# used for " & rCl.Offset(0, -1)
End If
End With
do_something:
'code
End Sub
You wouldn't need the check if you used ComboBoxes for the IDs & Serial numbers populated by existing numbers
Bookmarks