You are here:

Excel/Unprotecting dynamic rows in a protected worksheet


Hi Jerry,

Need your help in doing the below task using Formula/Macro.

I would like to unprotect the dynamic rows where it contains the word "Production Plan (Units) - Revised" in column B.

As per this example I would like to unprotect the cells C7:H7, C10:H10, C15:H15. I want to unprotect the whole row after the cell contains particular text (i.e. "Production Plan (Units) - Revised" in this case).

Please note that range will be dynamic. Please let me know if you have any question.!144&authkey=!AMmQq1D4vCEcXEo

Put this event macro into the sheet module where you want this behavior.  We'll assume you've already unlocked the column B cells so they are editable while the sheet is locked.

The macro watches for changes in column B.  Anytime you edit the column B values, the cells C:H on that same row will lock/unlock based on whether or not the B value is "Production Plan (Units) - Revised"

Option Explicit

Private Sub WOrksheet_Change(ByVal Target As Range)
Dim cell As Range

Me.Unprotect "Password"      'correct the password or remove if no password

For Each cell In Target
    If Not Intersect(cell, Range("B:B")) Is Nothing Then
        Range("C" & cell.Row).Resize(, 6).Locked = (cell.Value = "Production Plan (Units) - Revised")
    End If
Next cell

Me.Protect "Password"

End Sub

About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Jerry Beaucaire


Excel Formulas, macros, automation. Microsoft Excel MVP - 2010. Code site with free code snippets and techniques:


Microsoft Excel MVP - 2010. I have my own extensive Excel help/code site: ===================== I have been offering free assistance as an Excel aid on many web sites for many years: ( - JBeaucaire) ======== ( - JBeaucaire) ======= ( - jbeaucaire)

Bachelor's Degree from Azusa Pacific University in Mathematics and Music Composition

Awards and Honors
Microsoft Excel MVP 2010

©2017 All rights reserved.