Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Protecting and Unprotecting several worksheets at one time Learning Excel Excel Discussion (Misc queries) 8 February 4th 09 10:07 PM
Macro for protecting and unprotecting multiple worksheets saltnsnails Excel Discussion (Misc queries) 7 January 24th 08 10:49 PM
Password Protecting/Unprotecting Worksheets using VBA code? Bob Phillips Excel Programming 0 January 7th 08 10:03 AM
Macro for unprotecting/protecting worksheets WITH passwords John Baker Excel Programming 2 July 7th 04 01:19 PM
Protecting & unprotecting worksheets pkley Excel Programming 1 January 7th 04 10:28 PM


All times are GMT +1. The time now is 08:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"