How to Check if Worksheet TAB is protected or Not

A

Ananth

Want to Check if Worksheet is protected or not. If not protected want to
protect with a password “Something†If it is protected ignore action.

How to do this programatically
 
J

Jacob Skaria

If ActiveWorkbook.Sheets("Sheet2").Visible = -1 Then
ActiveWorkbook.Sheets("sheet2").Protect Password:="password"
ActiveWorkbook.Sheets("Sheet2").Visible = False
End If
 
S

Stefi

If Not ActiveSheet.ProtectContents Then _
ActiveSheet.Protect Password:="Something", DrawingObjects:=True,
Contents:=True, Scenarios:=True

Regards,
Stefi

„Ananth†ezt írta:
 
D

Dave Peterson

With worksheets("SomesheetNameHere")
If .ProtectContents = True _
Or .ProtectDrawingObjects = True _
Or .ProtectScenarios = True Then
'do nothing, it's already protected
Else
.Protect Password:="Something"
End If
End With
 

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