+ Reply to Thread
Results 1 to 3 of 3

VBA code stops working when I lock the workbook for use

  1. #1
    Registered User
    Join Date
    11-30-2012
    Location
    alberta, canada
    MS-Off Ver
    Excel 2010
    Posts
    39

    VBA code stops working when I lock the workbook for use

    Hello all,

    I have recently moved into the testing of a very large excel document for my place of work and after I locked everything that I do not with for those using it to touch all of my vba stopped working. I was wonding if there is a way to lock pages but not hinder the vba's access to information?

    Anything would be helpful,
    Sleepyshy

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA code stops working when I lock the workbook for use

    1) Let the workbook unlock and lock itself again when the workbook is opened and during the "lock again" process, add the parameter UserInterfaceOnly=True to the lock command. This parameter does not survive the workbook being closed and reopened, so you have to set it again.

    Once this is set this way, VBA can continue to operate on those sheets since the "lock" only applies to Users, not to VBA.

    You can Google more information / examples of this parameter quite handily.


    2) Change all your macros so they unlock the sheet(s)... do their stuff... then lock the sheet again.


    I would use #1 as it's less work.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    11-30-2012
    Location
    alberta, canada
    MS-Off Ver
    Excel 2010
    Posts
    39

    Re: VBA code stops working when I lock the workbook for use

    Hello,

    Thanks for the response! I will probably go with number 1 for simplicities sake.

    Have a great day,
    Sleepyshy

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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