Consulting

Results 1 to 2 of 2

Thread: Protected Sheet and Data Validation

  1. #1
    VBAX Regular
    Joined
    Jun 2010
    Posts
    8
    Location

    Protected Sheet and Data Validation

    I'm having a problem with running some code on a protected sheet. The code in question handles the data validation for particular cells when they are selected. I initially got run-time errors because the macros were protected, so I used the worksheet.protect method and the UserInterfaceOnly argument:

    [vba]Sheets("7. Equip Schedule").Protect "password", userinterfaceonly:=True[/vba]
    This did not work at first, but I then learned that data validation uses drawing objects, so I tried:

    [vba]
    Sheets("7. Equip Schedule").Protect "password", userinterfaceonly:=True, DrawingObjects:=False[/vba]
    This worked, sort of. My code runs properly and updates cell data validation as desired. However, despite the sheet being protected, cells which are locked are still editable by the user. So it's essentially not protected. I tried:

    [vba]
    Sheets("7. Equip Schedule").Protect "password", Contents:= True, userinterfaceonly:=True, DrawingObjects:=False[/vba]
    This fixes the protection of locked cells but the run-time errors return.

    Has anyone experienced a similar issue? Any suggestions?

    Thanks.

  2. #2
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    It might help if you posted the whole code. Snippets are hard to debug.
    Peace of mind is found in some of the strangest places.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •