+ Reply to Thread
Results 1 to 8 of 8

lock cells from within vba

  1. #1
    Registered User
    Join Date
    11-29-2020
    Location
    india
    MS-Off Ver
    2021
    Posts
    92

    lock cells from within vba

    i have some cells with functions codes applied to generate the output of it based on fixed cells input....how do i lock these cells from with vba so no one can edit them and it shud be in place from the time the file is opened

    i tried the below code but nothing works

    Please Login or Register  to view this content.

  2. #2
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: lock cells from within vba

    Try changing 'ActiveSheet' to 'Worksheets("Cal")'

  3. #3
    Registered User
    Join Date
    11-29-2020
    Location
    india
    MS-Off Ver
    2021
    Posts
    92

    Re: lock cells from within vba

    i am still to edit the cell

  4. #4
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: lock cells from within vba

    Can you post a copy of the workbook?

  5. #5
    Registered User
    Join Date
    11-29-2020
    Location
    india
    MS-Off Ver
    2021
    Posts
    92

    Re: lock cells from within vba

    maybe the sub is not getting applied hen the workbook is opened...m i supposed to add any other line so it applies on load

  6. #6
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: lock cells from within vba

    Copy and paste this into the Thisworkbook code module...
    Please Login or Register  to view this content.
    and this in a standard code module...
    Please Login or Register  to view this content.
    Then save the workbook, close it and then reopen it.

  7. #7
    Registered User
    Join Date
    11-29-2020
    Location
    india
    MS-Off Ver
    2021
    Posts
    92

    Re: lock cells from within vba

    but it locks the whole sheet not just the selected cells

  8. #8
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: lock cells from within vba

    In excel, all cells are locked by default. Try...
    Please Login or Register  to view this content.
    Last edited by dangelor; 06-16-2021 at 07:10 AM.

+ 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. Replies: 0
    Last Post: 05-30-2019, 12:13 PM
  2. [SOLVED] how to lock selected cells lock in excel
    By koteswar in forum Excel General
    Replies: 10
    Last Post: 10-25-2018, 02:38 AM
  3. [SOLVED] Lock cells with formula to prevent manual data entry into those cells.
    By jitterbug888 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-02-2015, 12:24 AM
  4. [SOLVED] How to make Macro to lock certain cells connected to another cells value, then copy daily
    By RamiSaydi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-29-2014, 12:41 PM
  5. Replies: 5
    Last Post: 07-15-2013, 03:57 AM
  6. Replies: 2
    Last Post: 02-22-2012, 10:10 AM
  7. Can I lock cells or do I have to lock the worksheet?
    By jmbtexas in forum Excel General
    Replies: 4
    Last Post: 11-11-2008, 02:26 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