+ Reply to Thread
Results 1 to 5 of 5

Sorting a protected shared worksheet

  1. #1
    Forum Contributor
    Join Date
    07-28-2005
    Posts
    132

    Sorting a protected shared worksheet

    Hi....I would like to protect some areas of a shared worksheet which has command buttons linked to macros. The macros are used mainly for sorting and its these that im having problems with. When I protect the shared workbook it wont run a sort macro from a command button. I have tried adding a line to the macro unprotecting the sheet and then another line protecting it again but I get "unprotect method of worksheet failed" error message. My ability with VB is very limited and Im using Excel 2007. Hope somebody can help with this.

    Many thanks and regards.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Sorting a protected shared worksheet

    Change the way your macros protect the sheets to include the UserInterfaceOnly:=True flag, or just add it into the top of your sort macros so it turns on that capability if it's not on already. Once that flag is set, macros can manipulate the protected document, though users still cannot.

    Please Login or Register  to view this content.
    This technique means you don't have to ever unprotect the sheet in VBA to run your macros.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    07-28-2005
    Posts
    132

    Re: Sorting a protected shared worksheet

    Thanks for the response...I will try your suggestion at work tomorrow and let you know how I get on.

    Regards

    Nigel

  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: Sorting a protected shared worksheet

    Quote Originally Posted by JBeaucaire View Post
    Change the way your macros protect the sheets to include the UserInterfaceOnly:=True flag, or just add it into the top of your sort macros so it turns on that capability if it's not on already. Once that flag is set, macros can manipulate the protected document, though users still cannot.

    Please Login or Register  to view this content.
    This technique means you don't have to ever unprotect the sheet in VBA to run your macros.
    You can't invoke protection in a shared workbook.
    It's one of Excel's wonderful restrictions.

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  5. #5
    Forum Contributor
    Join Date
    07-28-2005
    Posts
    132

    Re: Sorting a protected shared worksheet

    Hi DominicB

    I did try Jbeaucaire's suggestion and got the error message "Runtime error 1004 Application-defined or object-defined error" I am a little puzzled over the fact that I have managed to protect and share the worksheet, ticked the allow sorting option in the protection drop down menu and it worked fine from my PC (protected,shared and sorting from command button) but when I went to another PC in the network it gave the "workbook is in read only mode" error message when I tried to apply sort.

    Anyway....thanks for the info and taking an interest in my post.

    Regards

    Nigel

+ 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