Protect Range of Rows and Columns in Worksheet with Macro

April 4, 2009 by vba excel
Filed under: Excel Vba, Excel Worksheet 
Sponsor

Excel Vba Protect Range of Rows and Columns in Worksheet with Macro [Q]

I need help in protecting a range of rows and columns with excel vba macro code in Excel
worksheet. An Excel Workbook contains 14 worksheets (12 for each month, one for yearly total and one for description) More than 2000 employees use it. So I would appreciate if you could help me to do it using excel vba Macro or similar quick method.

Excel Vba Protect Range of Rows and Columns in Worksheet with Macro [A]

We assume you want to protect the same ranges on each of the 14 excel worksheets, so this is the microsoft excel vba macro code:

Sub ProtectAllSheets()
Application.ScreenUpdating = False
Dim N As Single
For N = 1 To Sheets.Count
With Sheets(N)
.Cells.Locked = False
.Range(”A1:B14″).Locked = True ‘adjust range to suit
.Protect Password:=”justme”
End With
Next N
Application.ScreenUpdating = True
End Sub

  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google
  • E-mail this story to a friend!
  • Live
  • MisterWong
  • Propeller
  • StumbleUpon
  • Technorati
  • TwitThis
  • YahooMyWeb
  • Print this article!

Rate This Tips:

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading ... Loading ...


Incoming excel search terms

excel vba protect,excel vba lock range,excel vba protect column,vba protect column,mss,vba protect range,excel vba lock cell,excel vba protect range,excel vba protect cells,excel vba protect columns,excel vba lock column,vba excel protect column,excel macro protect range,vba protect cells,vba protect row,excel vba lock worksheet,vba excel lock range,vba excel protect,vba protect columns,excel vba lock row,excel vba protect rows,excel vba range locked,how to protect column in excel,protect range vba,excel lock cells vba,excel vba range,excel vba range protect,protect cells vba,protect column vba,protect range,protect worksheet vba,range protect vba,vba lock cells,vba lock range,vba lock worksheet,vba protect spreadsheet range,vba range locked,excel lock cell with vba,excel vba protect worksheet,excel vba protection,how to protect a range of cells in excel,how to protect range of cells in excel,lock cells on multiple sheets excel vba,macro excel protect range,macro protect range,macro to protect cells,ph,protect column excel vba,protect columns in excel vba,range protect



Related Excel Tips

Comments

One Comment on Protect Range of Rows and Columns in Worksheet with Macro

    [...] short code snippets to solve particular problems in Excel using VBA and worksheet formulas. In Protect Range of Rows and Columns in Worksheet with Macro you can grab some sample code that demonstrates how to programmatically lock and protect a [...]

Have another excel answer or questions for this problem ?
Feel free to post it here..