+ Reply to Thread
Results 1 to 3 of 3

Password protecting sheets through VBA

  1. #1
    Eithne R
    Guest

    Password protecting sheets through VBA

    I want to password protect a spreadsheet / sheets but need to be able to
    unprotect them to manipulate them via a macro. Is this possible? The
    password option does not appear to be available in the protect method. Cheers

  2. #2
    Chip Pearson
    Guest

    Re: Password protecting sheets through VBA

    Use the UserInterfaceOnly flag of the Protect method. This
    prevents the user from modifying the sheet, but allows VBA to do
    anything. This property is not saved with the workbook, so you
    should protect the sheet(s) in the Workbook_Open event. E.g.,


    Private Sub Workbook_Open()
    Worksheets("Sheet1").Protect Password:="abc",
    userinterfaceonly:=True
    End Sub


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com



    "Eithne R" <[email protected]> wrote in message
    news:[email protected]...
    >I want to password protect a spreadsheet / sheets but need to be
    >able to
    > unprotect them to manipulate them via a macro. Is this
    > possible? The
    > password option does not appear to be available in the protect
    > method. Cheers




  3. #3
    Ron de Bruin
    Guest

    Re: Password protecting sheets through VBA

    Yes it is available

    ActiveSheet.Protect Password:="Ron"

    ActiveSheet.Unprotect Password:="Ron"


    --
    Regards Ron de Bruin
    http://www.rondebruin.nl


    "Eithne R" <[email protected]> wrote in message news:[email protected]...
    >I want to password protect a spreadsheet / sheets but need to be able to
    > unprotect them to manipulate them via a macro. Is this possible? The
    > password option does not appear to be available in the protect method. Cheers




+ 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