+ Reply to Thread
Results 1 to 5 of 5

Protected sheets w/macros giving runtime error 1004

  1. #1
    Registered User
    Join Date
    02-20-2009
    Location
    Mineral, VA
    MS-Off Ver
    Excel 2003
    Posts
    73

    Protected sheets w/macros giving runtime error 1004

    I created several macros objects to do simple hide columns, filter on, filter off, etc. type functions, using the Tools / Record Macro feature. Then discovered they won't work in a protected worksheet. Is there a way around this situation, other than turning protection off?

    Here's an example of the code for one of them, although I get the error or every attempt to perform a macro once the sheet is protected:

    Please Login or Register  to view this content.
    On top of the embarrassment of not realizing protecting worksheets that include macros cause a problem, I've never written a line of VBA code in my life.
    Last edited by cedarhill; 03-03-2009 at 08:01 AM.

  2. #2
    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

    Smile Re: Protected sheets w/macros giving runtime error 1004

    Good morning cedarhill
    Quote Originally Posted by cedarhill View Post
    On top of the embarrassment of not realizing protecting worksheets that include macros cause a problem, I've never written a line of VBA code in my life.
    We all have to start somewhere

    You will need to amend your code so that when the macro is run, the protection is removed, the filters are amended, and then the protection is set again. You can find out the syntax by recording the actions and editing as appropriate, but your code would look roughly like this :
    Please Login or Register  to view this content.
    This may change depending on what settings you have invoked, password etc.

    HTH

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

  3. #3
    Registered User
    Join Date
    02-20-2009
    Location
    Mineral, VA
    MS-Off Ver
    Excel 2003
    Posts
    73

    Re: Protected sheets w/macros giving runtime error 1004

    Actually, the code you provided does make sense to me, and I assume this code will have to be present with each macro I've recorded...true?

    And, yes, I do have password protection on. How do I handle that?

  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

    Smile Re: Protected sheets w/macros giving runtime error 1004

    Hi cedarhill
    Quote Originally Posted by cedarhill View Post
    Actually, the code you provided does make sense to me, and I assume this code will have to be present with each macro I've recorded...true?
    Absolutely.

    Quote Originally Posted by cedarhill View Post
    And, yes, I do have password protection on. How do I handle that?
    Like this :
    Please Login or Register  to view this content.
    See, it's easy this coding lark isn't it ...

    HTH

    DominicB

  5. #5
    Registered User
    Join Date
    02-20-2009
    Location
    Mineral, VA
    MS-Off Ver
    Excel 2003
    Posts
    73

    Re: Protected sheets w/macros giving runtime error 1004

    Well, thanks to you, I'm more than ready to "discover" the world of VBA coding. You're right...it's fun!

+ 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