Results 1 to 4 of 4

Thread: How to Automatically Protect Worksheet After Macro Runs?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    VBAX Mentor
    Joined
    Nov 2022
    Location
    The Great Land
    Posts
    452
    Location
    Protecting a sheet does nothing if cells are not set as Locked.

    First, cells you want to restrict must have Locked set. Then turn Protection on or off.

    Allowing selection of locked or unlocked cells is a feature of Protection. Right click on sheet tab then click ProtectSheet to view options.

    A locked cell is read only when Protection is on. It can be selected but attempting to type in it will trigger message.

    Code to protect/unprotect is simple.

    Just Protect or Unprotect will act on sheet that is active. Prefix with sheet name if you want to specify.

    Worksheets("sheetname").Protect
    However, there is nothing preventing any user to right click > unprotect unless you want to encrypt with password.

    By "shared" do you mean all user edits are supposed to be saved to same file?
    Last edited by June7; 05-20-2025 at 12:45 PM.
    How to attach file: Reading and Posting Messages (vbaexpress.com), click Go Advanced below post edit window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Posting Permissions

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