View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Josh Josh is offline
external usenet poster
 
Posts: 103
Default specific worksheet protection and auto run

Thanks!

"Gord Dibben" wrote:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim ws As Worksheet

For Each ws In ActiveWorkbook.Sheets(Array("Sheet2", "Sheet3"))
ws.Protect Password:="justme"
Next ws

End Sub

Entered in ThisWorkbook module.



Gord Dibben MS Excel MVP

On Thu, 4 Oct 2007 16:41:00 -0700, Josh wrote:

Greetings. Could someone please point me in the right direction with a bit
of code? I have a workbook with 50+ worksheets, but I only need a certain 2
worksheets protected. I also want this macro to run when I close the
workbook, so that I don't have to run the macro myself (I'd probably forget).
Could someone show me how to accomplish this task? Thanks