How do I protect all worksheet in an Excel workbook with a single click?

calendar_today Asked Oct 10, 2008
thumb_up 11 upvotes
history Updated April 16, 2026

Question posted 2008 · +5 upvotes

I have around 25 worksheets in my workbook (Excel spreadsheet). Is there a way I can protect all the 25 worksheets in single click ? or this feature is not available and I will have to write a VBA code to accomplish this. I need very often to protect all sheets and unprotect all sheets and doing individually is time consuming

Accepted answer +11 upvotes

I don’t believe there’s a way to do it without using VBA. If you are interested in a VBA solution, here is the code:

Dim ws as Worksheet
Dim pwd as String

pwd = "" ' Put your password here
For Each ws In Worksheets
    ws.Protect Password:=pwd
Next ws

Unprotecting is virtually the same:

Dim ws as Worksheet
Dim pwd as String

pwd = "" ' Put your password here
For Each ws In Worksheets
    ws.Unprotect Password:=pwd
Next ws

2 code variants in this answer

  • Variant 1 — 7 lines, starts with Dim ws as Worksheet
  • Variant 2 — 7 lines, starts with Dim ws as Worksheet

Top excel-vba Q&A (6)

+11 upvotes ranks this answer #55 out of 136 excel-vba solutions on this site .