+ Reply to Thread
Results 1 to 2 of 2

VBA Code To Lock Cells upon Opening File

  1. #1
    Registered User
    Join Date
    12-22-2020
    Location
    Washington D.C.
    MS-Off Ver
    Excel 2016
    Posts
    1

    VBA Code To Lock Cells upon Opening File

    I have a code (Shared Below), that locks a few different ranges of cells without protecting the entire sheet. My workbook has numerous sheets, and I am currently working on "Sheet 9". My objective is to lock these specific ranges of cells without protecting the entire sheet (sheet protection limits too many things for what I'm trying to do). I would also like for the VBA code to run automatically everytime the file is opened. Currently, my code only works by closing out of the VBA, clicking onto another sheet and then going back to "Sheet 9" to activate the sheet. I do not want for someone using the file to have to manually run the VBA to lock the specific cells. Any help will be greatly appreciated! Thank you!
    Please Login or Register  to view this content.
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #2 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer
    Last edited by 6StringJazzer; 12-22-2020 at 03:35 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,720

    Re: VBA Code To Lock Cells upon Opening File

    To run code upon opening, go to the module ThisWorkbook and add

    Please Login or Register  to view this content.
    The code in that Sub will run when the workbook is open, if the user enables macros.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VB code to check if file exit before opening excel file.
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-24-2017, 06:17 PM
  2. VBA to Lock and prevent opening of the excel file
    By Excelguruintraining in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-20-2015, 02:26 PM
  3. create code to lock spreadsheet after two hours from first opening and some more
    By DavidRoger in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-22-2015, 07:04 AM
  4. [SOLVED] VBA code for opening a file with a variable version number in the file name
    By trishcollins in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-04-2014, 04:38 PM
  5. [SOLVED] Error in code - play music file automatically after opening file
    By mukeshbaviskar in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-15-2013, 10:06 AM
  6. [SOLVED] Code for opening file if match with file name is found
    By cokillerliu in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-25-2013, 08:41 PM
  7. Replies: 1
    Last Post: 04-22-2005, 07:06 PM

Tags for this Thread

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