C
CAM
Hello,
I get this error everytime I press a command button "Run Time Error 57121"
Application-defined or object-define error.
What I did was copied a worksheet into a new workbook and adjust the
worksheet in my coding below. Why do I get this and How do I make my
program work? Any tip or website to visit will be appreciate. Thank you in
advance,
Private Sub cmdClear_Click()
'Message box
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "You are about to erase inputted cells. Press OK to proceed or No
to cancel."
Style = vbOKCancel + vbCritical + vbDefaultButton2
Title = "Erase Cells?"
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbOK Then .
MyString = "OK"
'Temporary unprotect worksheet
Worksheets("dept").Unprotect ("res")
'Error routine
On Error Resume Next
'Select sheet, cell range and clear inputted cells.
Worksheets("dept").Range("C13:F13").ClearContents
'Protect worksheet and allow column, row, and cell format
Worksheets("dept").Protect ("res"), DrawingObjects:=True,
Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True
'Notify user inputted cells has been cleared
MsgBox "Erase!", vbInformation + vbOKOnly, "erase Inputted
Cells"
'Error routine
On Error GoTo 0
Else
MyString = "Cancel" ' End program.
End If
End Sub
I get this error everytime I press a command button "Run Time Error 57121"
Application-defined or object-define error.
What I did was copied a worksheet into a new workbook and adjust the
worksheet in my coding below. Why do I get this and How do I make my
program work? Any tip or website to visit will be appreciate. Thank you in
advance,
Private Sub cmdClear_Click()
'Message box
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "You are about to erase inputted cells. Press OK to proceed or No
to cancel."
Style = vbOKCancel + vbCritical + vbDefaultButton2
Title = "Erase Cells?"
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbOK Then .
MyString = "OK"
'Temporary unprotect worksheet
Worksheets("dept").Unprotect ("res")
'Error routine
On Error Resume Next
'Select sheet, cell range and clear inputted cells.
Worksheets("dept").Range("C13:F13").ClearContents
'Protect worksheet and allow column, row, and cell format
Worksheets("dept").Protect ("res"), DrawingObjects:=True,
Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True
'Notify user inputted cells has been cleared
MsgBox "Erase!", vbInformation + vbOKOnly, "erase Inputted
Cells"
'Error routine
On Error GoTo 0
Else
MyString = "Cancel" ' End program.
End If
End Sub