+ Reply to Thread
Results 1 to 9 of 9

Lock row based on cell value in same row

  1. #1
    Registered User
    Join Date
    08-20-2013
    Location
    Swindon
    MS-Off Ver
    Excel 2003
    Posts
    13

    Lock row based on cell value in same row

    Hello, wondering if you can help me. I'm very new to writing macros...

    I've got a template spreadsheet, which will contain certain validation lists, formulas and conditional formats.
    Data is then imported into columns A:E, and after that I'd then like to run a macro.
    One of the things I'd like it to do is if cells in column E contain the word "Header", I'd like it to remove any existing validation lists in that row and lock the entire row for editing.
    (there is no set amount of rows; this will differ each time).

    How would I write this in VBA?

    Your help is much appreciated

    Regards, Eline

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Lock row based on cell value in same row

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-20-2013
    Location
    Swindon
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Lock row based on cell value in same row

    Thank you for getting back to me so quickly.

    For some reason, the above VBA doesn't seem to be doing anything? Help?

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Lock row based on cell value in same row

    You are going to have to be a bit more specific.

    Uploading a workbook with the code in as you are using it would help.
    -How are you triggering the code to run?
    -Is header case sensitive?


    I did double check and the code works if I put Header in E1 in a new workbook and run it, column E becomes locked.

  5. #5
    Registered User
    Join Date
    08-20-2013
    Location
    Swindon
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Lock row based on cell value in same row

    Apologies for not being clear.
    I am creating a seperate macro and am running it by going into Tools/Macro/Macros (for now).
    It will always say Header (caps H).
    If the cell in column E says Header, I would like the entire row of that cell to be locked (so not column E), if it says something else, I do not want this to be locked.

    Hope this explains your questions? Thank you

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Lock row based on cell value in same row

    I was aiming for something different, try this instead:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-20-2013
    Location
    Swindon
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Lock row based on cell value in same row

    This is great, thank you; it now removes the validation lists from the cells if column E contains Heading. It hasn't locked the row though, am I missing a step?
    (has this anything to do with locking and unlocking cells via Protecting the sheet?)

    Your help is truly much appreciated, thank you

  8. #8
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Lock row based on cell value in same row

    It will set the cell property locked to true, this is the same as right clicking the cell, clicking format, security and then locked check box. This doesn't actually "lock" the cell unless the sheet is protected.

  9. #9
    Registered User
    Join Date
    08-20-2013
    Location
    Swindon
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Lock row based on cell value in same row

    Brilliant, this is exactly what I was after! Thank you so so much for your help, you're a star!

+ 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. Unlock / Lock cell based on another cel value
    By BernardTodd in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-13-2013, 10:38 AM
  2. Replies: 1
    Last Post: 03-11-2013, 03:10 PM
  3. Replies: 1
    Last Post: 03-10-2013, 01:54 PM
  4. Lock cells within a row based on cell value
    By PY_ in forum Excel General
    Replies: 2
    Last Post: 11-14-2010, 12:40 AM
  5. [SOLVED] How to lock a row in a spreadsheet based on the value in a cell
    By Prasad in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-16-2005, 01:25 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