+ Reply to Thread
Results 1 to 3 of 3

Protect/Unprotect sheets (without activating them)

  1. #1
    Registered User
    Join Date
    01-10-2005
    Location
    Uk/Cheshire/poynton
    Posts
    2

    Protect/Unprotect sheets (without activating them)

    I would just like to know is it possible to protect and unprotect sheets without activating them, if so how please.

    When I use sheet1.protect

    And sheet1.unprotect

    Sheet1 is activated.

    i just need the sheet that is been protected/unprotected to not be activated as well. Any help please. thks

  2. #2
    Forum Contributor
    Join Date
    11-16-2004
    Posts
    282

    Turning Screen Updating on & off in a macro

    You can turn off screen updating before you protect/unprotect the sheet and then turn it back on like this:

    ' Turn off screen updating...
    Application.ScreenUpdating = False

    ' Your Protect/Unprotect code goes here...

    ' Turn on screen updating...
    Application.ScreenUpdating = True


    This method 'freezes' the screen to its current state so your macro actions are transparent to the user. This method is very useful if your macro is doing many manipulations of the cursor (i.e. scrolling through large data sets) or formatting of cells. It greatly improves the speed of the code execution because the screen doesn't have to show what is taking place. I'll test my code before using it to determine its' runtime; if it seems slow, I'll typically employ it.

    You can also notify the user of progress of your code execution in the status bar at the bottom of the Excel window while screen updating is turned off (the code below will display a message in the status bar, then pause for 2 seconds before continuing execution:

    ' Notify user of progress...
    oldStatusBar = Application.DisplayStatusBar
    Application.DisplayStatusBar = True
    Application.StatusBar = "Searching for files; please wait..."
    newHour = Hour(Now())
    newMinute = Minute(Now())
    newSecond = Second(Now()) + 2
    waitTime = TimeSerial(newHour, newMinute, newSecond)
    Application.Wait waitTime


    Here is the code to return the status bar to its' original state:

    Application.StatusBar = False
    Application.DisplayStatusBar = oldStatusBar






    Hope this helps,
    theDude

  3. #3
    Registered User
    Join Date
    01-10-2005
    Location
    Uk/Cheshire/poynton
    Posts
    2
    Thankyou very much, just what i needed.

+ 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