View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
dominicb[_120_] dominicb[_120_] is offline
external usenet poster
 
Posts: 1
Default Autofilter protected sheet


Good evening vecia

Only two new lines are needed, and we can get rid of one.

Sub Workbook_Open()
'check for filter, turn on if none exists
For Each ws In ActiveWorkbook.Worksheets
With ws
If Not .AutoFilterMode Then
.Range("A4:C4").AutoFilter
End If
.EnableAutoFilter = True
.Protect Password:="password", _
Contents:=True, UserInterfaceOnly:=True
End With
Next ws
End Sub

You no longer need to specify the spreadsheet, because they will all b
done, so that line has gone, but replaced by a For ... Next loop whic
will perform the action on each sheet in turn.

HTH

Dominic

--
dominic
-----------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...fo&userid=1893
View this thread: http://www.excelforum.com/showthread.php?threadid=46640