+ Reply to Thread
Results 1 to 2 of 2

macro help

  1. #1
    flow23
    Guest

    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. #2
    Dave Peterson
    Guest

    Re: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1