Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("sameday")
'find first empty row in database
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
'check for a date
If Trim(Me.txtdate.Value) = "" Then
Me.txtdate.SetFocus
MsgBox "Please enter a date"
Exit Sub
End If
'copy the data to the database
'use protect and unprotect lines,
' with your password
' if worksheet is protected
With ws
' .Unprotect Password:="password"
.Cells(iRow, 1).Value = Me.txttime.Value
.Cells(iRow, 2).Value = Me.txtname.Value
.Cells(iRow, 3).Value = Me.txtrego.Value
.Cells(iRow, 4).Value = Me.txtcompany.Value
.Cells(iRow, 5).Value = Me.txtdate.Value
.Cells(iRow, 6).Value = Me.txtmonth.Value
.Cells(iRow, 7).Value = Me.txtweek.Value
' .Protect Password:="password"
End With
'clear the data
Me.txttime.Value = ""
Me.txtname.Value = ""
Me.txtrego.Value = ""
Me.txtcompany.Value = ""
Me.txtname.Date = ""
Me.txtrego.Month = ""
Me.txtcompany.week = ""
Me.txttime.SetFocus
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub txtcompany_Change()
End Sub
Private Sub txtdate_Change()
End Sub
Private Sub txtmonth_Change()
End Sub
Private Sub txtname_Change()
End Sub
Private Sub txtrego_Change()
End Sub
Private Sub txtweek_Change()
End Sub
Private Sub UserForm_Click()
End Sub