+ Reply to Thread
Results 1 to 3 of 3

Macro wont work when sheet is protected

  1. #1
    Forum Contributor
    Join Date
    09-19-2012
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    137

    Macro wont work when sheet is protected

    When I use the macro with the sheet protected I get run-time error '1004': "you cannot use this command on a protected sheet"

    Please Login or Register  to view this content.
    Is there a workaround for this or do I have to apply the filter the old-fashioned way? I would like to be able to simply press a button linked to the macro, even when the sheet is protected.
    Last edited by Willardio; 09-21-2012 at 07:43 PM.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Macro wont work when sheet is protected

    Hi, Willardio,

    there are two ways you may handle this problem. First is unprotect the sheet before action and protect thereafter, the second is to protect the sheet via VBA in your Workbook_Open and use the parameter UserInterfaceOnly:=True which will enable macros to change data but normal usage still is prohibited.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Your macro should then work on Sheet Test.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Contributor
    Join Date
    09-19-2012
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    137

    Re: Macro wont work when sheet is protected

    Excellent Holger, thanks once again.

+ 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