Thread: Protection
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
tjh tjh is offline
external usenet poster
 
Posts: 96
Default Protection

Hello,

I am trying to use the code below to protect all the tabs in an excel file
if the tab color has not been changed or appears grey. The code does not seem
to be checking every tab, it only works for the tab that is active and does
not continue to the next tabs. Can you please help me determine why it is not
working?

Thank you,

Dim wks As Worksheet

For Each wks In ActiveWorkbook.Worksheets
If wks.Tab.ColorIndex = xlColorIndexNone Then
ActiveSheet.Protect Password:=" ", DrawingObjects:=True,
Contents:=True, Scenarios:=True
Else
End If
Next wks

MsgBox "The Workbook is Protected"