+ Reply to Thread
Results 1 to 5 of 5

Locking an unlocked row when you save pr make the next row active

  1. #1
    Registered User
    Join Date
    05-25-2007
    Posts
    19

    Locking an unlocked row when you save pr make the next row active

    I have an excel sheet set up for parts check in, and it is highly important none of it gets deleted unless i want it to.

    I have all unessesary cells locked, and password protected. all cells after 'E' are locked, and the cells in each ro before 'E' are unlocked.

    What i need to do is every time someone completes a row and moves on to the next row, i want it to lock that last completed row once the next one is activated. Or i could have it to where when you save the document, it locks only the activated rows, where the data is entered.

    This souds complicated to me, and i cant figure it out. i hope this wasnt too confusing becasue it is kind of complicated.

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Put this in the code module for the critical sheet.
    Please Login or Register  to view this content.
    The _Change routine will lock the columns A-E of a row once all of those cells are filled. If only some of those cells are empty, all 5 cells are unlocked.

    The Worksheet Activate routine sets Protection.UserInterfaceOnly to True, so that VB code can change the sheet (i.e. lock cells), even though the user can't.

    Is this what you wanted?

  3. #3
    Registered User
    Join Date
    05-25-2007
    Posts
    19
    it sounds right, but the coding is getting an error: "RUn time error '1004'
    unable to set locked property of range class" i have marked where the debug is catching:

    Please Login or Register  to view this content.
    Last edited by VBA Noob; 05-28-2007 at 03:38 PM.

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Your sheet is protected. For testing, you need to trigger an Activate event. Select another sheet and then go back to sheet1.

    HEY!!, I just found out that opening a workbook does not trigger a Worksheet_Activate event.
    Put this in the ThisWorkbook code module
    Please Login or Register  to view this content.
    That needs to run just once per session. Workbook_Open is another event that would work.

  5. #5
    Registered User
    Join Date
    05-25-2007
    Posts
    19
    thanks alot, that did the trick

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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