+ Reply to Thread
Results 1 to 4 of 4

Error macro - Protecting Sheet

  1. #1
    Forum Contributor
    Join Date
    06-25-2012
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2010
    Posts
    201

    Error macro - Protecting Sheet

    Hi i have a macro that runs over a protected sheet. So for it to run first i have a code that unlocks it using the password of the sheet
    Please Login or Register  to view this content.
    . At the ende of the code i just put the same code for protecting it again putting Protect instead of unportect. The problem is that this kind of protection only allows the user to select the cells and enter values. I want it to have the option to format the cells and collumns too. When i recorded a macro with this i came up with this code:
    Please Login or Register  to view this content.
    It now works fine, and i'm able to format cells but the password dont input so if the user presses unlock it unlocks because has no pass. When i try to add the Password code at the end or beginnig of this new code i get the error presented in the attached image. Can you tell me whats wrong?
    The code i'm trying to use is this:
    Please Login or Register  to view this content.
    Attached Images Attached Images

  2. #2
    Forum Contributor
    Join Date
    06-25-2012
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2010
    Posts
    201

    Re: Error macro - Protecting Sheet

    Really needed a help in here...

  3. #3
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,615

    Re: Error macro - Protecting Sheet

    1. this code:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    compiles without error.


    2. Your code:
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
    , AllowFormattingCells:=True, AllowFormattingColumns:=True Password:="123"
    has a syntax error; you misplaced the comma

    3. You only waited about 20 minutes before expecting an answer. Remember that the members are volunteers working in their own spare time, and there may not be anyone around. The rule is wait 24 hrs before "bumping".
    Last edited by protonLeah; 01-04-2013 at 08:10 PM.
    Ben Van Johnson

  4. #4
    Forum Contributor
    Join Date
    06-25-2012
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2010
    Posts
    201

    Re: Error macro - Protecting Sheet

    @ProtonLeah

    As you write your response i figured it out too searching on goole. It was only a comma. lol A little thing makes the diference. But really thanks for the help.
    By the way do you know how can i do this in this post? http://www.excelforum.com/excel-gene...00#post3068800

+ 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