Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
With this code, the user would have to push "save" before he/she can close
the document in order for the protection to run. Is there a way to accomplish the same task without having to save? For instance, if the user unprotected the worksheet, updated cells, saved, pushed exit (code runs) pushed "don't save" (user thinking he/she doesn't need to save again), the worksheet would be unprotected. Thoughts? "Josh" wrote: 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 |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Josh
If user says "No" to saving when closing, the BeforeClose will run anyway. Gord On Mon, 8 Oct 2007 17:02:14 -0700, Josh wrote: With this code, the user would have to push "save" before he/she can close the document in order for the protection to run. Is there a way to accomplish the same task without having to save? For instance, if the user unprotected the worksheet, updated cells, saved, pushed exit (code runs) pushed "don't save" (user thinking he/she doesn't need to save again), the worksheet would be unprotected. Thoughts? "Josh" wrote: 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 |
#6
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Maybe I should ask...........did you have a problem with the scenario you
described? Or did you just not test it? Gord On Mon, 08 Oct 2007 19:24:01 -0700, Gord Dibben <gorddibbATshawDOTca wrote: Josh If user says "No" to saving when closing, the BeforeClose will run anyway. Gord On Mon, 8 Oct 2007 17:02:14 -0700, Josh wrote: With this code, the user would have to push "save" before he/she can close the document in order for the protection to run. Is there a way to accomplish the same task without having to save? For instance, if the user unprotected the worksheet, updated cells, saved, pushed exit (code runs) pushed "don't save" (user thinking he/she doesn't need to save again), the worksheet would be unprotected. Thoughts? "Josh" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
auto filters and worksheet protection | Excel Worksheet Functions | |||
Cell Protection vs. Worksheet Protection | Excel Discussion (Misc queries) | |||
Cell protection & Auto Filter | Excel Worksheet Functions | |||
Worksheet protection is gone and only wokbook protection can be se | Excel Discussion (Misc queries) | |||
auto protection of cells | Excel Worksheet Functions |