+ Reply to Thread
Results 1 to 11 of 11

vba to lock the entire row

  1. #1
    Forum Contributor
    Join Date
    07-17-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    715

    vba to lock the entire row

    Hi,

    Below is the code which update the timestamp in the adjustment column when the value is entered in C or E column.

    Please Login or Register  to view this content.
    Now my last step is to lock the entire row when E column is updated or lock all filled cell. So next user update on the the next cell/row which is not updated. I tried lot of option, but my entire sheet is getting locked instead just a row.
    Last edited by shiva_reshs; 08-22-2018 at 07:01 AM.
    Keep the Forum clean :


    1. Use [ code ] code tags [ /code ]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    2. Show appreciation to those who have helped you by clicking * Add Reputation below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: vba to lock the entire row

    Good afternoon shiva_reshs

    What you will need to do is highlight all cells, then go to Format Cells > Protection and untick the Locked box to unlock all your cells.

    Then set workbook protection through your Review tab : all cells should be editable as you will have unlocked them.


    You can then use code like this to lock an entire row (note that the worksheet will need unprotecting first, and reprotecting after).
    Please Login or Register  to view this content.
    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  3. #3
    Forum Contributor
    Join Date
    07-17-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    715

    Re: vba to lock the entire row

    Good After DominicB,

    Thanks for assist. I tried your code but it turns red on below line with syntax error. am i missing something to tag?

    Please Login or Register  to view this content.
    Last edited by shiva_reshs; 08-22-2018 at 07:26 AM.

  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: vba to lock the entire row

    Hi shiva_reshs

    Apologies - I used without testing. Try this :
    Please Login or Register  to view this content.
    Needless to say, make sure it's being used after you define xRow.

    HTH

    DominicB

  5. #5
    Forum Contributor
    Join Date
    07-17-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    715

    Re: vba to lock the entire row

    Hi Dominicb,

    This works perfect. But as you see from the code my vba capture the timestamp when the cell value is changed. With the code that i have added to lock, the moment i touch the cell in E column, the entire row is locked. This doesnt allow me to update the E cell to update as the row is already locked.

    Any workaround for this?

  6. #6
    Forum Contributor
    Join Date
    07-17-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    715

    Re: vba to lock the entire row

    I tried to do this to overcome this challenge.

    Please Login or Register  to view this content.

    And did module call

    Please Login or Register  to view this content.
    now am getting 424 Object required on xRow = Target.Row

  7. #7
    Forum Contributor
    Join Date
    07-17-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    715

    Re: vba to lock the entire row

    Couple of attempt. this is i tried to make it neat.

    Please Login or Register  to view this content.
    After first attempt which is successfully done, when i do it on second line i get below error msg on the red line above.

    Run - time Error 1004

    Unable to set the Number Format property of the Range Class

  8. #8
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: vba to lock the entire row

    Hi shiva_reshs

    Let's go back to post 5 first.

    Can you post the whole file - I don't need all the data, just a few rows of dummy data.

    Explain to me what happens and what should happen and we'll take it from there. Once we get that working, we'll have a look at any outstanding issues from what you have put in posts 6 and 7.

    HTH

    DominicB

  9. #9
    Forum Contributor
    Join Date
    07-17-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    715
    here is the attachment. Am sorry, should have done that earlier.
    Attached Files Attached Files

  10. #10
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: vba to lock the entire row

    Hi shiva_reshs

    Have a look at the attachment.
    I have removed your code and replaced it with a module that should put in a date into column F when column B is completed. I have also added a module that locks the row when an option in column E is selected.

    Let me know how this goes.

    HTH

    DominicB
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    07-17-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    715

    Re: vba to lock the entire row

    Hi Dominicb,

    Thanks a lot. Made some modification per my need and now it works perfectly for my need.
    Attached Files Attached Files

+ 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. Lock entire Row if Value in Col A = X
    By walsha23 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-31-2017, 07:00 AM
  2. Lock entire Row if Value in Col A = X
    By walsha23 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 10-26-2017, 10:38 AM
  3. it is possible to lock entire ROW
    By baig123 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-10-2014, 05:24 AM
  4. [SOLVED] Lock entire column if data has been entered in it
    By bassterro in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-01-2014, 03:25 PM
  5. [SOLVED] Lock an entire row
    By kid_epicurus in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-20-2012, 12:33 PM
  6. Replies: 13
    Last Post: 03-13-2012, 06:24 AM
  7. How do change entire worksheet to uppercase letters and lock it
    By aeromutt in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-01-2006, 12:10 PM

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