Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Protecting and Unprotecting more than 1 worksheets
Hi all. Is it possible to protect and unprotect more than 1
worksheets. Say the first 4 worksheet in a workbook using VBA codes? Thanks much. Jeff |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Protecting and Unprotecting more than 1 worksheets
Sub Protect_Some_Sheets()
Application.ScreenUpdating = False Dim N As Single For N = 1 To 4 'for all sheets use N = 1 to Sheets.Count Sheets(N).Protect Password:="justme" Next N Application.ScreenUpdating = True End Sub Gord Dibben MS Excel MVP On Mon, 7 Jul 2008 14:36:55 -0700 (PDT), Jeffrey wrote: Hi all. Is it possible to protect and unprotect more than 1 worksheets. Say the first 4 worksheet in a workbook using VBA codes? Thanks much. Jeff |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Protecting and Unprotecting more than 1 worksheets
Or this for selected sheets.
Sub Protect_Selected_Sheets() Set MySheets = ActiveWindow.SelectedSheets For Each ws In MySheets ws.Select ws.Protect Password:="justme" Next ws End Sub Gord On Mon, 07 Jul 2008 14:52:13 -0700, Gord Dibben <gorddibbATshawDOTca wrote: Sub Protect_Some_Sheets() Application.ScreenUpdating = False Dim N As Single For N = 1 To 4 'for all sheets use N = 1 to Sheets.Count Sheets(N).Protect Password:="justme" Next N Application.ScreenUpdating = True End Sub Gord Dibben MS Excel MVP On Mon, 7 Jul 2008 14:36:55 -0700 (PDT), Jeffrey wrote: Hi all. Is it possible to protect and unprotect more than 1 worksheets. Say the first 4 worksheet in a workbook using VBA codes? Thanks much. Jeff |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Protecting and Unprotecting more than 1 worksheets
On Jul 8, 9:53*am, Gord Dibben <gorddibbATshawDOTca wrote:
Or this for selected sheets. Sub Protect_Selected_Sheets() Set MySheets = ActiveWindow.SelectedSheets For Each ws In MySheets *ws.Select * *ws.Protect Password:="justme" Next ws End Sub Gord On Mon, 07 Jul 2008 14:52:13 -0700, Gord Dibben <gorddibbATshawDOTca wrote: Sub Protect_Some_Sheets() * *Application.ScreenUpdating = False * *Dim N As Single * *For N = 1 To 4 'for all sheets use *N = 1 to Sheets.Count * * * *Sheets(N).Protect Password:="justme" * *Next N * *Application.ScreenUpdating = True End Sub Gord Dibben *MS Excel MVP On Mon, 7 Jul 2008 14:36:55 -0700 (PDT), Jeffrey wrote: Hi all. Is it possible to protect and unprotect more than 1 worksheets. Say the first 4 worksheet in a workbook using VBA codes? Thanks much. Jeff- Hide quoted text - - Show quoted text - Hi Gord, Thanks much. This works very well. Cheers. Jeff |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Protecting and Unprotecting more than 1 worksheets
On Jul 8, 1:36*am, Jeffrey wrote:
Hi all. Is it possible to protect and unprotect more than 1 worksheets. Say the first 4 worksheet in a workbook using VBA codes? Thanks much. Jeff it is very simple. loop through the sheets protecting each one in turn Eg: Sub Doit() i = 1 Do Until i = 4 Sheets(i).Activate ActiveSheet.Protect i = i + 1 Loop End Sub End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Protecting and Unprotecting several worksheets at one time | Excel Discussion (Misc queries) | |||
Macro for protecting and unprotecting multiple worksheets | Excel Discussion (Misc queries) | |||
Password Protecting/Unprotecting Worksheets using VBA code? | Excel Programming | |||
Macro for unprotecting/protecting worksheets WITH passwords | Excel Programming | |||
Protecting & unprotecting worksheets | Excel Programming |