+ Reply to Thread
Results 1 to 5 of 5

For double Loop with Rows & Locked Cells

  1. #1
    Registered User
    Join Date
    03-24-2016
    Location
    Canada
    MS-Off Ver
    Mac
    Posts
    63

    Angry For double Loop with Rows & Locked Cells

    Hello!

    I am trying to make a loop that cycles through a specific range of cells if the contents of one cell contains "Y"

    Basically:

    All Cells are not locked
    All Cells look normal
    Cells within the range of C4:Q4 are locked and greyed out
    If B4 = "Y" then C4 becomes unlocked, B4 & B3 changes color (light green fill dark green text), C4 Returns to the default color,
    otherwise it remains locked
    If C4 = "Y" then D4 becomes unlocked, C4 & C3 changes color (light green fill dark green text), C4 Returns to the default color,
    otherwise it remains locked

    This continues as a loop until it reaches the end.
    It would keep doing this check every time I enter something in the unlocked box.

    i have some code I wrote from a lot of googling and a rusty knowledge of a cs course from university.

    Please Login or Register  to view this content.
    Also I'm on a MAC smh :\ if that makes a difference.

    I need some help, I have a VERY general understanding of VBA, but not the right kind of knowledge to get exactly where I need to go.

    Any suggestions?

  2. #2
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: For double Loop with Rows & Locked Cells

    Not sure how the code changes on a MAC, but in general:

    Locking/unlocking has no effect unless the sheet is Protected. So, in your code, if you want to change the locked/unlocked status you need to Unprotect the worksheet at the front end.

    If before protecting the first time you've set the cell properties to Unlocked for everything except C4:Q4, then you don't need to change the locked/unlocked status of anything, just first unprotect the sheet, apply your changes, then reprotect the sheet. http://analysistabs.com/excel-vba/pr...ct-worksheets/

    I'm assuming you're going to have a user who's going to input a value in B4, which, if it's Y, triggers everything to happen. If so, that's a Worksheet Change Event, which goes into the specific Worksheet object module, not a standard code module. B4 will be the trigger.http://www.excel-easy.com/vba/events.html

  3. #3
    Valued Forum Contributor
    Join Date
    08-07-2014
    Location
    Quito, Ecuador
    MS-Off Ver
    Excel 2016 & 365, Windows 10
    Posts
    511

    Re: For double Loop with Rows & Locked Cells

    @ legnak

    Try with this code
    I'm assuming the "Y" can come from any formula or calculation or manual change.
    it checks all the range B4:Q4 for "Y", and change cells as you asked,
    but I'm not sure about your needs
    I've used simple beginners coding, so you can learn a bit.

    Please Login or Register  to view this content.
    Barriers are there for those who don't want to dream

  4. #4
    Registered User
    Join Date
    03-24-2016
    Location
    Canada
    MS-Off Ver
    Mac
    Posts
    63

    Re: For double Loop with Rows & Locked Cells

    trying to compile, but getting an error:

    Member already exists in an object module from which this object module derives.


    Any suggestions?

  5. #5
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: For double Loop with Rows & Locked Cells

    From a Microsoft Help file:
    Please Login or Register  to view this content.

+ 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. [SOLVED] VBA to allow users to delete specific rows with locked cells on protected sheets
    By JT12345 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-13-2015, 02:46 PM
  2. Copy and paste locked cells, and have pasted cells retain LOCKED status.
    By stratloveslenny in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-16-2014, 03:05 PM
  3. Replies: 3
    Last Post: 04-12-2014, 04:47 AM
  4. Inserting copied rows (some locked cells, some not) in a protected sheet
    By kmartinez0180 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-07-2014, 08:09 PM
  5. Can I reorder rows with locked cells?
    By mrgrotey in forum Excel General
    Replies: 3
    Last Post: 01-04-2013, 10:34 AM
  6. Replies: 0
    Last Post: 01-03-2009, 06:47 PM
  7. Deleting rows with locked cells
    By Paul Moore in forum Excel General
    Replies: 3
    Last Post: 06-18-2005, 01:05 AM

Tags for this Thread

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