+ Reply to Thread
Results 1 to 2 of 2

VBA to lock rows where cell contains a 1 value

  1. #1
    Registered User
    Join Date
    05-15-2024
    Location
    UK
    MS-Off Ver
    365
    Posts
    1

    VBA to lock rows where cell contains a 1 value

    Hi there,

    I am a novice with VBA but I have a code which is in a sheet with a large product list and there is a column which contains a "1" if the date the product was entered is before today.
    When the sheet is selected I want it to activate the macro and lock all cells containing the 1s. It does do this but if you enter new data - i,e you insert a new row into the table (say inbetween two existing products) when you try and populate that cell with data it is locked even though the column is blank (i.e. no 1)
    The code is:

    Please Login or Register  to view this content.
    Just to state there is two other macros in the sheet, one to essentially drag formula down from the row above when a new row is inserted (for some specific columns) -this doesnt work either, and another which highlights the row selected - this does currently work.
    The column with the '1's is based on a formula that references a column which the user enters a date manually into (i.e. when they create the product item). My ideal solution would have been to just lock the rows with the dates older than today which is what this code was originally based on but I had the same problem.

    The code for these just in case is:

    Please Login or Register  to view this content.
    and

    Please Login or Register  to view this content.
    Any help would be much appreciated.

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,877

    Re: VBA to lock rows where cell contains a 1 value

    It would be easier to help and test possible solutions if you could attach a copy of your file. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary). See the yellow banner at the top of this page for instructions to attach a file.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

+ 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 rows when adjacent cell is marked OK
    By jaboo9995 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-27-2023, 05:27 PM
  2. Lock specific rows according actual date and lock always columns A and B
    By thorblow in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-12-2022, 05:17 PM
  3. How to delete blank rows in cell lock sheet
    By sudbhavani in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-03-2020, 01:22 PM
  4. Replies: 8
    Last Post: 08-08-2019, 01:01 PM
  5. [SOLVED] Macro to lock rows with value in a corresponding cell while unlock the other rows
    By wowow in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-06-2016, 10:57 PM
  6. lock/unlock rows based on values in cell
    By aravindhan_31 in forum Excel General
    Replies: 5
    Last Post: 06-14-2012, 03:33 PM
  7. [SOLVED] I want to copy a formula down several rows and lock a cell ref.
    By abcdbaker in forum Excel General
    Replies: 3
    Last Post: 11-23-2005, 10:55 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