+ Reply to Thread
Results 1 to 14 of 14

Autofilter on a protected sheet

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,954

    Autofilter on a protected sheet

    Okay, I can find a thousand hits on my title, but none fix my problem.

    I have a workgroup created by another group. The worksheet in question is protected, but they've applied an autofilter which I can manually manipulate.
    When I record my manual manipulation, I get this:
    Please Login or Register  to view this content.
    However, when I try to run that same macro, I get a run-time error saying I can't use this command on a protected sheet. How do I manipulate the autofilter via a macro in this kind of case?

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: Autofilter on a protected sheet

    You need to set the protection for that sheet, but allow the filter.

    Example:
    Please Login or Register  to view this content.
    HTH
    Regards, Jeff

  3. #3
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,954

    Re: Autofilter on a protected sheet

    That's the problem; it's not my sheet. I don't set the protection, I just get to work with the protected sheet.

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: Autofilter on a protected sheet

    Then I think you are out of luck.

    Can they not do this from where you get the sheet from?

  5. #5
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,954

    Re: Autofilter on a protected sheet

    Depends on what you mean by "can they not do this". As stated, when I get the sheet, an autofilter has been applied, but nothing selected. So when I get it I can click the autofilter on the various columns and choose, for instance, "Jomili" in column I, or "Region 2" in column B. So they HAVE allowed the autofilter, and I CAN select the options I want. I merely want a macro to select those options, and that's where my difficulty lies.

  6. #6
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: Autofilter on a protected sheet

    Ok on a quick test here is what I see.

    When you recieve the sheet the filter is applied and you can manually select whatever you like; however, you try to run a macro and you get the "you can't".

    I setup the same scenario, but to allow the macro to run, when setting the passord I used >> userinterfaceonly:=True

    Please Login or Register  to view this content.
    So from what I see, in the end, before the password is set on the sheet the command to allow macros to run has to be set.

    Please let me know if this help at all.

  7. #7
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,954

    Re: Autofilter on a protected sheet

    Not really in this case. The group that creates it isn't open to suggestions to allow more access. By allowing the manual filter they figure they're done enough. So I'm not going to be able to do the "userInterfaceOnly" part.

  8. #8
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Autofilter on a protected sheet

    then your options are to filter manually or remove the password and do what you want ;-)
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  9. #9
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,954

    Re: Autofilter on a protected sheet

    Maybe that's what I'll do; I'll break the password, harvest the data I need, then close it without saving. Yeah, that'll work. Let me try that out and get right back to you.

  10. #10
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Autofilter on a protected sheet

    if you're just harvesting data I wouldn't bother opening the workbook at all-I'd just query it

  11. #11
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,954

    Re: Autofilter on a protected sheet

    Care to explain further?

  12. #12
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Autofilter on a protected sheet

    well it depends on what you mean exactly by harvesting data but I was referring to using ado to query the worksheet as a table-you can use where clauses in the same way you would use an autofilter to restrict the data you get back

  13. #13
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Autofilter on a protected sheet

    example code
    Please Login or Register  to view this content.

  14. #14
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,954

    Re: Autofilter on a protected sheet

    I actually went with what I think is a better way; rather bothering with all the autofiltering and stuff, I can achieve my goals through a VLookup. The problems in this are that the workbook name and location vary, and the column containing my desired data wanders through the sheet. I've achieved a clunky success with the code below; I'd like to find a way to identify the MFR workbook and sheet with a variable and use that in my VLookup formula rather than opening the workbook, saving to my desktop with a standard, then closing it. Any ideas?
    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