I have a form with a texbox titled "Guestname" and I would like to add the name on the sheet with the button (which I already have written down) and on a different sheet titled "Total Guests".
I would also like to do a couple more things too. On the form I have two CheckBoxes, titled "MSbox" and "ONbox". and if they are checked I would like it to fill in "MS" in column 5 and "ON" in column 6. I know I have to use the If Then statements, but I am unaware of where to put them in the code.
Here is the current code I have for the submit button:
Private Sub SubmitButton_Click()
Dim emptyRow As Long
Dim emptyCol As Long
Dim Res As Variant
emptyCol = 2
With Sheet1
Res = Application.Match(Guestname.Value, .Columns(1), 0)
If Not IsError(Res) Then
emptyCol = .Cells(Res, Columns.Count).End(xlToLeft).Offset(, 1).Column
If emptyCol > 4 Then
MsgBox "All 3 visits have been used"
Exit Sub
End If
emptyRow = Res
Else
emptyRow = .Range("A" & Rows.Count).End(xlUp).Row + 1
End If
Cells(emptyRow, 1).Value = Guestname.Value
Cells(emptyRow, emptyCol).Value = Roomnum.Value
End With
Unload Name_usrfrm
End Sub
Bookmarks