+ Reply to Thread
Results 1 to 9 of 9

Problems with AutoFilter and Protect Sheet

  1. #1
    Registered User
    Join Date
    05-04-2008
    Posts
    7

    Problems with AutoFilter and Protect Sheet

    I have a file containing data, formulas and derived data. Essentially the formulas use the data to produce the derived data values. Macros are triggered by clicking one of four buttons - one to refresh detail views, one to refresh summary views, and two others that simply move the page view either to the left or to the right. I'm included a copy of one of the two macros that refresh the data at the end of this note.

    Before I commented out the Protect commands, what I was trying to accomplish was to prevent users from being able to change the actual data and from also seeing the formulas. In preparation to use these macros, I used the Format/Cells/Protection selection in Excel to explicitly lock and/or hide the appropriate columns. Next I used the Tools/Protection/Protect Sheet selection to protect the worksheet. Afterwards I started testing the macros by clicking the buttons I set up on the sheet.

    The macros that shift the page views from left to right and visa-versa can be used right up to the point when I start experiencing problems triggering the other macros. These are CopyRight2Left and FilterCopyRight2Left, the ones that specifically refresh the derived data values and Protect or UnProtect the worksheet. Then the macros buttons I set up on the sheet could not be clicked. I had to manually UnProtect the worksheet in order to use the buttons again. But as soon as the sheet becomes protected again using the macros that refresh the derived data values, the same problem occurred. None of the macro buttons on the worksheet would work.

    Please let me know what I need to change to get things working properly.

    Thank you.

    ---------------- Macro Follows -----------------
    Please Login or Register  to view this content.
    Last edited by royUK; 07-08-2008 at 02:42 AM. Reason: add code tags, edit time expired

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Please read the Forum Rules and then wrap your code with Code Tags.

  3. #3
    Registered User
    Join Date
    05-04-2008
    Posts
    7

    Macro Buttons Don't Always Work

    I've been trying to add some security to my macro code. Unfortunately I'm having a bit of trouble and I need some help.

    The file that I'm working with has a worksheet containing data, formulas, and derived data. Essentially the formulas use the data to produce the derived data values. The macros are used to refresh the derived data values. There are two macros that I use by clicking one of two buttons - one to refresh detail view, one to refresh the summary view. I use the AutoFilter command in the first macro to toggle off the summary view created by the second macro.

    Attached is a copy of both macros.

    Please Login or Register  to view this content.
    As is, the macro code without the Protect commands works perfectly. That's because I've commented out the various Protect commands. As part of the macro code, the Protect commands were meant to prevent users from being able to change the actual data and from also seeing the formulas.

    In preparation to use these macros, I used the Format/Cells/Protection selection in Excel to explicitly lock and/or hide the appropriate columns. Next I used the Tools/Protection/Protect Sheet selection to protect the worksheet. I activate these macros by clicking buttons I set up on the sheet.

    The first few times I use the macros, they work as intended. But it seems that after any of them lock the sheet, I cannot click on any of the macro buttons I’ve set up on the sheet. I have to go and manually UnProtect the worksheet in order to use the buttons again. But as soon as the sheet becomes protected again using the macros, I’m faced with exactly the same problem. None of the macro buttons on the worksheet work.

    Please let me know what I need to change to get things working properly.

    Thank you.
    Last edited by StanPok; 07-08-2008 at 01:22 AM. Reason: Insert Code Tags

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Stan, second request: Please read the Forum Rules and then wrap your code with Code Tags.

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    What buttons have you used/ If they are from the Controls toolBox (ActiveX) then have you exited Design View?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Registered User
    Join Date
    05-04-2008
    Posts
    7

    Response to RoyUK

    Hi RoyUK,

    The two buttons used to trigger the macros were created by drawing boxes into which I inserted text descriptions of the action to be performed. I assigned macros to each of the boxes.

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Protecting the sheet shouldn't stop you from clicking them.

  8. #8
    Registered User
    Join Date
    05-04-2008
    Posts
    7
    Quote Originally Posted by royUK
    Protecting the sheet shouldn't stop you from clicking them.
    I don't know how to respond other than saying that the problem seems to be caused by the AutoFilter command. If the Protect command is commented out, the AutoFilter command will execute, and it will either toggle on or off the drop-down box at the top of each column, and everything works perfectly.

    But when the Protect Sheet command is inserted into the macro and executes, whenever the AutoFilter command executes and the drop-down boxes appear, the macro buttons no longer work.

    Is there a parameter missing from the AutoFilter command?

  9. #9
    Registered User
    Join Date
    05-04-2008
    Posts
    7

    Solution Found

    After much code experimentation, I finally got everything working the way I want. If you're interested in seeing it, the revised code follows:

    Please Login or Register  to view this content.

+ 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