Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Need code to protect worksheets - amount of worksheets varies

Hello!

I need code that will protect worksheets and the
workbook. There are many workbooks involved and depending
on the particular workbook, it will have X amount of
worksheets in it with various names.

Also, I need to hide certain sheets in each workbook -
those will always be the same.

Any suggestions will be greatly appreciated!

Sandy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Need code to protect worksheets - amount of worksheets varies

heres a macro that i use all the time

this protects all the sheets and the workbook


Sub protect()

Dim i As Integer
' Loop through all sheets in the workbook.
' change this for the number of sheets
For i = 1 To Sheets.Count
Sheets(i).protect "PASSWORD", True, True, True
'Range("A1").Select
Next i
'protect workbook
ActiveWorkbook.protect Structu=True, Windows:=False
ActiveWorkbook.protect "PASSWORD", True, False
End Sub


Sub unprotect()


Dim i As Integer
' Loop through all sheets in the workbook.
' this can also be set to a number
For i = 1 To Sheets.Count
Sheets(i).unprotect "PASSWORD"
'Range("A1").Select
Next i
ActiveWorkbook.unprotect "PASSWORD"
End Sub


hope this helps

kevin

"Sandy" wrote in message
...
Hello!

I need code that will protect worksheets and the
workbook. There are many workbooks involved and depending
on the particular workbook, it will have X amount of
worksheets in it with various names.

Also, I need to hide certain sheets in each workbook -
those will always be the same.

Any suggestions will be greatly appreciated!

Sandy



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
Code to protect all the worksheets in a book bill_ball New Users to Excel 1 June 10th 10 08:06 AM
Maximum amount of worksheets in single file Stuart Excel Discussion (Misc queries) 3 September 15th 06 08:06 PM
Copying multiple rows to other worksheets (but amount of rows varies) - How? David Smithz Excel Discussion (Misc queries) 1 June 18th 06 04:31 PM
Can I password protect worksheets? mocity Excel Worksheet Functions 2 May 23rd 06 01:07 AM
How can I protect worksheets in one go? Lincie L. Excel Worksheet Functions 1 August 6th 05 06:11 PM


All times are GMT +1. The time now is 09:00 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"