+ Reply to Thread
Results 1 to 5 of 5

Lock entire Row if Value in Col A = X

Hybrid View

  1. #1
    Registered User
    Join Date
    12-09-2014
    Location
    Wicklow, Ireland
    MS-Off Ver
    Win 7
    Posts
    25

    Lock entire Row if Value in Col A = X

    Hi

    I'm looking for some help, i think its an easy fix but im not to sure, In the attached workbook you will see in column A there is an X in certain rows.

    What I'm looking for is if there is an X in column A it locks that entire row

    Thanks for the help in advance

    Adam
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,658

    Re: Lock entire Row if Value in Col A = X

    I've moved your thread, as you'll need VBA for this.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Lock entire Row if Value in Col A = X

    Hi Adam

    Place this Code in the Worksheet Module...
    Option Explicit
    
    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim LR As Long
        If Not Target.Column = 1 Then Exit Sub
        If Target.Value = "X" Then
            Target.EntireRow.Locked = True
            ActiveSheet.Protect _
                    DrawingObjects:=True, _
                    Contents:=True, _
                    Scenarios:=True, _
                    UserInterfaceOnly:=True
            ActiveSheet.EnableSelection = xlUnlockedCells
        End If
    End Sub
    Attached Files Attached Files
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  4. #4
    Registered User
    Join Date
    12-09-2014
    Location
    Wicklow, Ireland
    MS-Off Ver
    Win 7
    Posts
    25

    Re: Lock entire Row if Value in Col A = X

    Hi John

    The above works ok but it doesnt give me the ability to make changes if i need to

    Adam

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,333

    Re: Lock entire Row if Value in Col A = X

    How about this ?
    Attached Files Attached Files
    Last edited by bakerman2; 10-31-2017 at 07:37 AM. Reason: Slight change to code.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

+ 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. How to lock cell width and height for an entire worksheet
    By vaughnahue in forum Excel General
    Replies: 4
    Last Post: 05-31-2018, 10:14 AM
  2. 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
  3. [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
  4. Time lock an entire workbook - even unprotected cells
    By AlexanderTheAverage in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-22-2012, 01:57 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