Hi I have a button on a worksheet (menu). when the user clicks on it it must check they filled in some data which works. It then runs a macro called compile this macro asks them to select which workbooks they want to combine they select the workbooks it then opens the workbooks up and pastes in to the relevant sheet. It then emails the data off to me. NOW for the problem. once compile is finished it then needs to clear the sheets that figures are in. It then tells me that the worksheet is protected which I dont understand as I have unprotected the sheet to input the data which has worked it does not get put on it debugs at the spot where theis. I stop the code and check under tools/protection and it is not protected.
Can somebody help?
Below is my code followed by my error message
Private Sub CommandButton1_Click()
If Range("c2").Value = "" Or Range("c2").Value = "<Blank>" Then
MsgBox "Please enter in your area name"
Range("c2").Activate
Exit Sub
ElseIf Range("n2").Value = "" Then
MsgBox "Please enter in your the month you are compiling."
Range("n2").Activate
Exit Sub
ElseIf Range("p2").Value = "" Then
MsgBox "Please enter in your the year you are compiling."
Range("p2").Activate
Exit Sub
End If
Worksheets("1").Unprotect otherPassword
Worksheets("2").Unprotect otherPassword
Worksheets("3").Unprotect otherPassword
'run code to extract data from other workbooks & email data off
compile
'Clear the sheets that have data
Sheets("1").Select
Range("F9:k28").ClearContents![]()
![]()
![]()
![]()
![]()
![]()
Sheets("2").Select
Range("F9:K28").Select
Selection.ClearContents
Sheets("LCIS").Select
Range("3").Select
Selection.ClearContents
Sheets("menu").Select
Range("a1").Activate
Worksheets("1").Protect otherPassword
Worksheets("2").Protect otherPassword
Worksheets("3").Protect otherPassword
Sheets("menu").Activate
ComboBox1.Value = "<Blank>"
ComboBox2.Value = "<Blank>"
ComboBox3.Value = "<Blank>"
End Sub
My Error Message: Runtime Error 1004: The cell or chart you are trying to change is portected and therefore read-only.
To modify a protected cell or chart, first remove protection using the Unprotect sheet command (Tools mennu, Protection Submennu) you may be prompted for a password
Bookmarks