How to Check if Worksheet TAB is protected or Not

  • Thread starter Thread starter Ananth
  • Start date Start date
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
 
If ActiveWorkbook.Sheets("Sheet2").Visible = -1 Then
ActiveWorkbook.Sheets("sheet2").Protect Password:="password"
ActiveWorkbook.Sheets("Sheet2").Visible = False
End If
 
If Not ActiveSheet.ProtectContents Then _
ActiveSheet.Protect Password:="Something", DrawingObjects:=True,
Contents:=True, Scenarios:=True

Regards,
Stefi

„Ananth†ezt írta:
 
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
 
Back
Top