#1   Report Post  
Posted to microsoft.public.excel.misc
flow23
 
Posts: n/a
Default macro help

I have the following macro that protects all sheets and allows changes to
pivot table.

However I only want some sheets to be protected and not all. Is there a way
I can assign the sheet names to this?

I have excel 2000

On Error Resume Next
' Err.Clear
Dim sh As Worksheet, sh1 As Worksheet
Set sh1 = ActiveSheet
For Each sh In ThisWorkbook.Worksheets
sh.Select
sh.EnablePivotTable = True
sh.Protect Contents:=True, UserInterfaceOnly:=True
Next
sh1.Activate
Sheets("front sheet").Select
Range("b8").Select
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default macro help

Maybe just looping through the worksheets and checking their names...

For each sh in thisworkbook.worksheets
select case lcase(sh.name)
case is = "sheet1","sheet5","sheet17"
'do one thing
case is = "sheet2","sheet54","sheet88"
'do a different thing
case else
'do nothing at all
end select
next sh

If you only have two categories, you could use one "case is =" line and use the
"case else" for all the other sheets.

flow23 wrote:

I have the following macro that protects all sheets and allows changes to
pivot table.

However I only want some sheets to be protected and not all. Is there a way
I can assign the sheet names to this?

I have excel 2000

On Error Resume Next
' Err.Clear
Dim sh As Worksheet, sh1 As Worksheet
Set sh1 = ActiveSheet
For Each sh In ThisWorkbook.Worksheets
sh.Select
sh.EnablePivotTable = True
sh.Protect Contents:=True, UserInterfaceOnly:=True
Next
sh1.Activate
Sheets("front sheet").Select
Range("b8").Select


--

Dave Peterson
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
Search, Copy, Paste Macro in Excel [email protected] Excel Worksheet Functions 0 January 3rd 06 06:51 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
macro with F9 Kenny Excel Discussion (Misc queries) 1 August 3rd 05 02:41 PM
Make Alignment options under format cells available as shortcut dforrest Excel Discussion (Misc queries) 1 July 14th 05 10:58 PM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM


All times are GMT +1. The time now is 01:14 AM.

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"