+ Reply to Thread
Results 1 to 5 of 5

Macro Code to individually password protect a sheet

  1. #1
    Registered User
    Join Date
    08-26-2017
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    2

    Macro Code to individually password protect a sheet

    Hi everybody. Now I am sure this has been asked 1000 times over, but after searching for an hour I just couldn't find anything!

    I am looking for the most basic code or solution to password all sheets with an individual password.

    Any help would be highly appreciated.

    Zane

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro Code to individually password protect a sheet

    Hi Zane, welcome to the forum
    Well, I don't know where you are looking but Google offers enough solutions.
    The simplest is record your own macro.
    Start the macro recorder and password protect one worksheet, make sure you select the things you still want allowed like Autofilter and select unprotected as well as protected cells
    Stop the macro recorder an look at the code.
    You can then copy this code and apply it to other sheets with another password.
    Keep in mind that you must remember them to unprotect the worksheets.

    If you're stuck, just holler and explain a little more what you want to do
    Happy coding
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Macro Code to individually password protect a sheet

    What do you mean by this ?
    all sheets with an individual password
    Is it every sheet with a different password or all sheets with 1 password.
    If it's the first you need to create an array of passwords equal to the number of sheets and loop through the array and sheets.
    Or you can come up with some sort of algorithm to create a unique password for every sheet.
    In the second case it's just a matter of looping through sheets and assigning the samme password every time.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  4. #4
    Registered User
    Join Date
    08-26-2017
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    2

    Re: Macro Code to individually password protect a sheet

    Hi guys,

    thanks for the help.

    So let me explain further. Keebellah, thanks for the thoughts into Macro recorder. But I don't think that will work in this instance.

    So I have a workbook with 8 different worksheets in it. So I need to protect each worksheet with a different password. Not protect the cells from being altered (that I do know how to do), but each individual worksheet with its own password so when it is attempted to be opened, a password is required to even access that sheet.

    Hope that clears things up and thanks again.

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Macro Code to individually password protect a sheet

    This is how it works.
    Make an extra start sheet where you can redirect when wrong password.
    Put below code in sheetmodule of all to be protected sheets.
    Amend password and return sheetname.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Creating a macro to password protect each sheet
    By alex2damax in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-16-2015, 01:37 AM
  2. [SOLVED] [VBA CODE] Password Protect a hidden sheet while using other code
    By cityinbetween in forum Excel General
    Replies: 11
    Last Post: 09-26-2014, 03:15 AM
  3. [SOLVED] Macro to filter and protect sheet with password
    By GregTheSquarePeg in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-10-2013, 05:42 AM
  4. [SOLVED] Password protect sheet - modify code
    By eXtremer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-02-2013, 08:46 AM
  5. Replies: 0
    Last Post: 06-27-2012, 10:38 PM
  6. Protect Sheet & Password Protect Code
    By KLahvic in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-13-2009, 04:08 PM
  7. [SOLVED] Protect Sheet - VB code to specify password
    By Darin Kramer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-01-2005, 05:06 AM

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