Results 1 to 9 of 9

Problems with AutoFilter and Protect Sheet

Threaded View

  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 -----------------
    Sub CopyRight2Left()
    
        Dim myCell As Range
    
        Application.DisplayAlerts = False
        Application.ScreenUpdating = False
    
        Sheets("2-Year Data").Select
    
     '  ActiveSheet.Unprotect Password:=""
     '  ActiveSheet.Protect Password:="", UserInterFaceOnly:=True
    
    ' Save the current cell location
        Set myCell = ActiveCell
        Columns("B:AO").Select
        Selection.AutoFilter
    
      Sheets("2-Year Data").Range("GG3:GV14060").Copy
      Sheets("2-Year Data").Range("I3").PasteSpecial Paste:=xlPasteValues
      Sheets("2-Year Data").Range("I3").PasteSpecial Paste:=xlPasteFormats
    
      Sheets("2-Year Data").Range("HA3:HM14060").Copy
      Sheets("2-Year Data").Range("AC3").PasteSpecial Paste:=xlPasteValues
      Sheets("2-Year Data").Range("AC3").PasteSpecial Paste:=xlPasteFormats
    
        myCell.Select
        
     ' ActiveSheet.Protect Password:=""
     
       Application.ScreenUpdating = True
        Application.ScreenUpdating = True
        
    End Sub
    Last edited by royUK; 07-08-2008 at 02:42 AM. Reason: add code tags, edit time expired

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