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,mss,excel vba lock range,excel vba protect column,excel vba protect range,vba protect column,vba protect range,excel vba lock cell,excel vba protect cells,,excel vba protect columns,excel macro protect range,excel vba lock column,vba excel protect column,excel vba lock worksheet,macro to protect cells,vba lock cells,vba protect cells,vba protect row,excel vba lock row,ph,vba excel lock range,vba excel protect,vba excel protect range,vba protect columns,vba protect worksheet,excel vba protect cell,excel vba protect rows,excel vba range,excel vba range locked,how to protect column in excel,protect column vba,protect range vba,protect worksheet vba,excel lock cells vba,excel lock row vba,excel vba protect row,excel vba protect worksheet,excel vba range protect,macro protect range,protect cells vba,protect range,range protect vba,vba lock range,vba lock worksheet,vba protect spreadsheet range,vba range locked,excel lock cell with vba,excel protect column vba,excel vba lock cell range



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..