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

0 votes
About 25 worksheets are in my workbook (Excel spreadsheet). Is it possible for me to safeguard all 25 worksheets with a single click? Alternatively, if this feature is not available, I will need to create some VBA code to complete my task. I frequently need to protect and unprotect all of my linens and doing it one at a time takes time.
Oct 21 in Others by Kithuzzz
• 20,660 points
33 views

1 answer to this question.

0 votes

VBA 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
answered Oct 22 by narikkadan
• 37,660 points

Related Questions In Others

0 votes
1 answer
0 votes
1 answer

How can I use a command button in excel to set the value of multiple cells in one click?

Try this: Private Scan As Integer Private Sub CommandButton1_Click() ...READ MORE

answered Oct 24 in Others by narikkadan
• 37,660 points
62 views
0 votes
1 answer

How do I insert a WebP-image (".jpg") in Excel using VBA?

It's not currently on the list of ...READ MORE

answered Nov 15 in Others by narikkadan
• 37,660 points
39 views
0 votes
1 answer

How do I get an Excel range using row and column numbers in VSTO / C#?

Use: int countRows = xlWorkSheetData.UsedRange.Rows.Count; int countColumns = xlWorkSheetData.UsedRange.Columns.Count; object[,] ...READ MORE

answered Nov 17 in Others by narikkadan
• 37,660 points
33 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,720 points
452 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
2,220 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9 in Others by gaurav
• 22,040 points
69 views
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16 in Others by Edureka
• 13,640 points
207 views
0 votes
1 answer

How do I combine the first character of a cell with another cell in Excel?

Try this: =CONCATENATE(LEFT(A1,1), B1) READ MORE

answered Nov 7 in Others by narikkadan
• 37,660 points
29 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP