
Originally Posted by
royUK
You need to unprotect the sheet first
Sheet1.Unprotect "your password"
'your code
Sheet1.Protect "your password"
I tried this and got the same thing. Here's the code I used. Name was still Sheet1, but I don't yet have a password to unprotect it yet since right now I'm just trying to get it to work.
Private Sub cmdSubmit1_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("MAIN")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for a name
If Trim(Me.txtName1.Value) = "" Then
Me.txtName1.SetFocus
MsgBox "Please enter member's name"
Exit Sub
End If
Sheet1.Unprotect ""
'copy data to database
ws.Cells(iRow, 1).Value = Me.txtRate1.Value
ws.Cells(iRow, 2).Value = Me.txtName1.Value
ws.Cells(iRow, 3).Value = Me.txtDivision1.Value
ws.Cells(iRow, 4).Value = Me.txtRcvd1.Value
ws.Cells(iRow, 5).Value = Me.txtLoss1.Value
Sheet1.Protect ""
'clear the data
Me.txtName1.Value = ""
Me.txtRate1.Value = ""
Me.txtDivision1.Value = ""
Me.txtRcvd1.Value = ""
Me.txtLoss1.Value = ""
Me.txtName1.SetFocus
End Sub
Bookmarks