You are here:

Excel/Unprotecting dynamic rows in protected worksheet

Advertisement


Question
Hi Bob,

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.


https://skydrive.live.com/redir?resid=A1B8470E44E28CE2!144&authkey=!AMmQq1D4vCEcXEo

Answer
run this macro:

Sub Prot()
   ActiveSheet.Unprotect
   For i = 2 To Range("B1048576").End(xlUp).Row
       If Cells(i, 2).Value = "Production Plan (Units) - Revised" Then
         Cells(i, 3).Resize(1, 6).Locked = True
       Else
         Cells(i, 3).Resize(1, 6).Locked = False
       End If
   Next
   ActiveSheet.Protect
End Sub


But you will need to save the file as xlsm because xlsx files can't hold macros.
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

Excel

All Answers


Answers by Expert:


Ask Experts

Volunteer


Bob Umlas

Expertise

I`m a Microsoft Excel MVP (Most Valuable Professional) and have been since the inception of the program in 1995. I can answer every kind of Excel question except: API, Importing/exporting to other programs (powerpoint, word,...) Also check out my in-person training link at http://www.thumbtack.com/ny/new-york/excel-training/

Experience

Worked with MS Excel since version 0.99 (on the Mac!). Was contributing editor to Excellence Magazine, having written >300 articles. John Walkenbach said of me "I finally met someone who knows as much about Excel as I do."

Publications
Excellence, The Expert, Microsoft

Education/Credentials
BA in math, Hofstra University, 1965

Awards and Honors
MVP
Led sessions for the Convergence 2004-2006 seminar on Excel tips & tricks

©2016 About.com. All rights reserved.