+ Reply to Thread
Results 1 to 3 of 3

VBA - when click save button lock all cells with data in the workbook.

  1. #1
    Registered User
    Join Date
    10-01-2012
    Location
    Maharashtra
    MS-Off Ver
    Excel 2003
    Posts
    2

    Post VBA - when click save button lock all cells with data in the workbook.

    Hello all,

    I know its not something new and I have gone through many threads where the cell gets locked if its contains data. That is when we type and move to another cell it locks the cell which contain data.
    However, what I am looking for is, the cell should get locked only if:
    1. The cell is not blank and user click save (Ctrl+S)
    2. While closing we get an option to save and if the user clicks "OK".

    Because the user should get chance to amend any cell while reviewing and identifies typo error or had selected any incorrect option from a combo box (data validation).

    I have gone through below code and tried few stuffs but no idea how to involve save function in it which will lock all the cells in the workbook with data.
    Can anyone help me out with this.

    Please Login or Register  to view this content.
    Last edited by sanojv; 01-29-2019 at 07:09 AM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: VBA - when click save button lock all cells with data in the workbook.

    Checkout the Workbook_beforesave event, it is located in the workbook module.
    .
    WB_BeforeSave.jpg

  3. #3
    Registered User
    Join Date
    10-01-2012
    Location
    Maharashtra
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: VBA - when click save button lock all cells with data in the workbook.

    hello Davesexcel, thanks a lot for your response however, I tried it but getting an error.

    Please Login or Register  to view this content.
    and event I tired a new code as well but its not going with the BeforeSave event could you please help?

    Please Login or Register  to view this content.
    Last edited by sanojv; 02-02-2019 at 02:11 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. VBA to click button and transfer userform data to another workbook
    By joehigashi in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-22-2018, 11:58 PM
  2. Replies: 2
    Last Post: 01-09-2018, 11:39 AM
  3. [SOLVED] VBA Lock sheets and prompt password on button click
    By ironfelix717 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-28-2017, 04:20 PM
  4. Command button to save workbook with filename data from 2 cells??
    By Owen1976 in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 02-16-2016, 08:04 AM
  5. [SOLVED] VBA to click button and transfer userform data to another workbook
    By chin67326 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-15-2015, 02:39 PM
  6. [SOLVED] Compile Error: Method or data member not found when i click Save button...
    By aditbaco in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-15-2013, 07:11 AM
  7. Auto Lock Cells after Data Entry AND Save
    By ROSH22 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2012, 06:57 AM

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