Results 1 to 5 of 5

Thread: Protect/Unprotect Cells with VBA

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    So the error you are getting is when the user checks/unchecks the box, is that right? I assume that the code to toggle the "lock" on the cell.

    Try doing this:

    ActiveSheet.Unprotect
    'your regular code goes here
    ActiveSheet.Protect
    The other way to do this would be to put a Workbook_Open procedure in, which loops through each require sheet, and runs something like this:

    ActiveSheet.Protect userinterfaceonly:=True
    This would stop users from hitting your sheets, but let's macros do their thing. The only problem (and reason for the workbook_open routine) is that this setting disappears when you close the workbook.

    HTH,
    Last edited by Aussiebear; 12-21-2024 at 11:42 AM.
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





Posting Permissions

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