I changed it to this. I am having trouble with the other textbox now though. I fixed the last code using
If MSbox.Value = True Then
Res = Application.Match(GuestName.Value, .Columns(2), 0)
If Not IsError(Res) Then
emptyCol = Application.CountA("F", .Rows(Res))
emptyRow = Res
Else
emptyRow = .Range("F" & Rows.Count).End(xlUp).Row + 1
End If
Cells(emptyRow, 6).Value = "M/S"
End If
The other textbox checks another column for names and decides if they match, and if they do it has a msgbox. However, after that I want it to perform the same function as the MSbox, except for in the next column "G". I know it is wrong but I am confused as to how to get it to work.
If ONbox.Value = True Then
Oban = Application.Match(GuestName.Value, .Columns(15), 0)
If Not IsError(Oban) Then
MsgBox "Individual has had an overnight more than three times in a five month period. He/She is allowed back on: " & Range("P4"), vbOKOnly + vbCritical, "Overnight Ban"
GuestName.Value = ""
Roomnum.Value = ""
For Each ctl In Me.Controls
If TypeName(ctl) = "CheckBox" Then ctl.Value = False
Next ctl
Exit Sub
ElseIf Oban = Application.Match(GuestName.Value, .Columns(2), 0) Then
If Not IsError(Oban) Then
emptyCol = Application.CountA("G", .Rows(Oban))
emptyRow = Res
Else
emptyRow = .Range("G" & Rows.Count).End(xlUp).Row + 1
End If
Cells(emptyRow, 6).Value = "O/N"
End If
End If
Bookmarks