+ Reply to Thread
Results 1 to 7 of 7

Can't add Data Validation to Protected Sheet

  1. #1
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Can't add Data Validation to Protected Sheet

    I'm using a macro to add Data Validation (xlValidateList) to a sheet. I can only do it if the sheet is unprotected. I have the cells unlocked, and I'm using .Protect userinterfaceonly:=True to protect the sheet.

    Am I missing something that would let me add the Validation to a protected sheet?
    Foxguy

    Remember to mark your questions [Solved] and rate the answer(s)
    Forum Rules are Here

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Can't add Data Validation to Protected Sheet

    Without thinking too deeply, why not unprotect, add validation, and re-protect?

    My dim recollection is that UIO is not really as encompassing as it might be.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Can't add Data Validation to Protected Sheet

    Just reiterating shg's point - I don't believe you can modify the DV without doing as he says (ie UIO is not sufficient in this instance).

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Can't add Data Validation to Protected Sheet

    It's unreliable. Sometimes works, sometimes not. Much better to do as shg said.
    Remember what the dormouse said
    Feed your head

  5. #5
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: Can't add Data Validation to Protected Sheet

    romperstomper;

    I'm curious. This is the first time I've run across anything that didn't make sense to me when using userinterfaceonly.
    Do you know of other situations that don't work?

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Can't add Data Validation to Protected Sheet

    Data Validation is the only one I know of offhand that fails regularly but, as I tend to unprotect and reprotect anyway on the rare occasions I even bother with protection and have to alter something, I don't classify myself as an expert.

  7. #7
    Registered User
    Join Date
    12-10-2010
    Location
    California
    MS-Off Ver
    Excel all versions from 5.0 (1993) to 365
    Posts
    38

    Re: Can't add Data Validation to Protected Sheet

    i'm experiencing the same thing. strangely, as another pointed out, it does work sometimes.

    when i hit the error, i click "Debug", and then immediately continue running the code. then it works.

    the reason i would like to avoid the unprotect/protect cycle, is that i need to do this every single time the user clicks a cell on the sheet. so, in the interest of a quality user-experience, the code needs to be as quick as possible.

    the reason i need to remove the validation temporarily, and then immediately re-add it to the cells, is because ActiveWindow.RangeFromPoint is intercepted by in-cell dropdown lists.

    if i could find a way to get ActiveWindow.RangeFromPoint to work without disabling Validation.InCellDropdown, then i could avoid this whole issue! --and improve the user-experience.
    Last edited by johnywhy; 07-20-2011 at 08:33 PM.

+ 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