Un Protect in Excel 2000

G

Guest

I am trying to do the blow but it keeps coming up with run time errot 1004. I
am new at this and very confused. I need it to run utomatically at the click
of a button, any ideas?

Private Sub CommandButton1_Click()

' ActiveSheet.Unprotect "helen"

Range("C4:C7,H4:H7,C11:C14,H11:H14,C18:C21,G18:H21,C25:C28,H25:H28,I25:J28,C32:J34,N28,M29:p32,O21:O22,F1:I1").Select
Range("F1").Activate
Selection.ClearContents
Range("C4").Select
ActiveSheet.Protect
Range("a1").Select
ActiveCell.FormulaR1C1 = "Select Contract Length"
ActiveSheet.Protect "helen"

End Sub

Cheers

Helen
 
D

Dave Peterson

You have the first .unprotect line commented out.

Maybe unprotecting the worksheet would be a start.

And you have activesheet.protect in the middle. That could cause trouble later
on.


Maybe....

Option Explicit
Private Sub CommandButton1_Click()
With Me 'the sheet that holds the button
.Unprotect "helen"
.Range("C4:C7,H4:H7,C11:C14,H11:H14,C18:C21," & _
"G18:H21,C25:C28,H25:H28,I25:J28," & _
"C32:J34,N28,M29:p32,O21:O22,F1:I1").ClearContents
.Range("a1").Value = "Select Contract Length"
.Protect "helen"
End With
End Sub

If that doesn't work, make sure you indicate what line is causing the trouble.
It'll make it easier to guess a solution.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top