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(quot;front sheetquot;).Select
Range(quot;b8quot;).Select
Maybe just looping through the worksheets and checking their names...
For each sh in thisworkbook.worksheets
select case lcase(sh.name)
case is = quot;sheet1quot;,quot;sheet5quot;,quot;sheet17quot;
'do one thing
case is = quot;sheet2quot;,quot;sheet54quot;,quot;sheet88quot;
'do a different thing
case else
'do nothing at all
end select
next sh
If you only have two categories, you could use one quot;case is =quot; line and use the
quot;case elsequot; for all the other sheets.
flow23 wrote:
gt;
gt; I have the following macro that protects all sheets and allows changes to
gt; pivot table.
gt;
gt; However I only want some sheets to be protected and not all. Is there a way
gt; I can assign the sheet names to this?
gt;
gt; I have excel 2000
gt;
gt; On Error Resume Next
gt; ' Err.Clear
gt; Dim sh As Worksheet, sh1 As Worksheet
gt; Set sh1 = ActiveSheet
gt; For Each sh In ThisWorkbook.Worksheets
gt; sh.Select
gt; sh.EnablePivotTable = True
gt; sh.Protect Contents:=True, UserInterfaceOnly:=True
gt; Next
gt; sh1.Activate
gt; Sheets(quot;front sheetquot;).Select
gt; Range(quot;b8quot;).Select
--
Dave Peterson
- Feb 22 Thu 2007 20:35
macro help
close
全站熱搜
留言列表
發表留言