Skip to Content

How to execute "Lock Cells" button through VBA Macro?

Dear all,

The requirement is to lock input-ready cells on a Excel button click. We don't want to use the standard "Lock Cells" button provided in Planning Ribbon.

Button functionality is implemented in VBA Macro, But i am not able to find any information on How to trigget the AFO "Lock Cells" there. An option of Excel Locking is possible, but it only works when we protect the whole worksheet and in our case it is useless.

Any ideas?

Thanks & Regards,


Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Feb 25, 2015 at 03:01 AM

    The toggle between display and change button will give the functionality you are looking for. You will see the button once you enable the planning ribbon under AFO settings.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 04, 2016 at 10:21 AM

    Hi vamsi,

    did you find a solution for this problem?

    We have the same need in our project.

    Best regards,


    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Igor.

      I could not lock the cells using a macro but I reached something useful.

      • By using a macro I changed non-editable cells design, so they looked like "locked" cells. I attached this logic to the refresh workbook event.
      • By using a query inverse formula I rejected all changes done in these cells when transferring values to BW server.

      Best regards,


Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.