+ Reply to Thread
Results 1 to 5 of 5

Get macros to work on protected sheet

  1. #1
    Registered User
    Join Date
    12-16-2011
    Location
    scotland
    MS-Off Ver
    excel 2010
    Posts
    41

    Get macros to work on protected sheet

    Hi

    I have a data file with various added buttons with some very basic macros attached to the buttons to help me search & filter quickly , but i would like to protect the worksheet , but my macros are then disabled when i protect the worksheet is there away round this?

    cheers
    barry
    Last edited by howsitgoing; 01-12-2012 at 02:10 PM.

  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: can i get macros to wor on a protected work sheet

    In your macros you "Unprotect the sheet, run the code, protect the sheet again".


    Or

    Use a macro to protect your sheets in the first place and add the UserInterfaceOnly:=True to the protection parameters so that VBA is inherently allowed to keep working.
    _________________
    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
    Registered User
    Join Date
    12-16-2011
    Location
    scotland
    MS-Off Ver
    excel 2010
    Posts
    41

    Re: Get macros to work on protected sheet

    hi

    I have added a macro using the record function to protect the sheet with-out problem (thanks) , but any tips for where i place the "UserInterfaceOnly:=True" into the macro
    thanks
    barry

    Sub Macro6()
    '
    ' Macro6 Macro
    ' protect worksheet
    '

    '
    ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
    False, AllowFiltering:=True
    End Sub

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

    Re: Get macros to work on protected sheet

    No, just add it anywhere:
    Please Login or Register  to view this content.

    Thing to remember is that this parameter will not persist when the workbook is closed. The sheet stays protected, but this parameter is lost. When you reopen the sheet, you will need to reset the protection to activate that flag again for that session. Then your macros will keep working.

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  5. #5
    Registered User
    Join Date
    12-16-2011
    Location
    scotland
    MS-Off Ver
    excel 2010
    Posts
    41

    Re: Get macros to work on protected sheet

    hi

    thanks very much , that worked perfect

    cheers
    baz

+ 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