Hi, there!!
When searching the internet for an answer as to how I could protect all sheets in my workbook at one time, instead of having to protect each one individually, the only thing I found that would actually be a perfect fit was creating a macro.
I've never used a macro before, and know absolutely nothing about how to create one!
Given that, I attempted the following code that I found in another forum:
Can someone tell me why, and tell me how to correct it so that it works?
Thanks bunches!!
Ariana
When searching the internet for an answer as to how I could protect all sheets in my workbook at one time, instead of having to protect each one individually, the only thing I found that would actually be a perfect fit was creating a macro.
I've never used a macro before, and know absolutely nothing about how to create one!
Given that, I attempted the following code that I found in another forum:
Sub Protect_Me()
Dim x As Long
For x = 1 To Worksheets.Count
If Sheets(x).ProtectContents Then
Sheets(x).Unprotect Password:="MyPass"
Else
Sheets(x).Protect Password:="MyPass"
End If
Next
End Sub
When I tried to run it in Excel 2007, I got a Sytax Error, which shows the first line (Sub Protect_Me()) highlighted in yellow, with a little yellow arrow pointing to it. I'm assuming the program doesn't like this line. I couldn't tell you why! Dim x As Long
For x = 1 To Worksheets.Count
If Sheets(x).ProtectContents Then
Sheets(x).Unprotect Password:="MyPass"
Else
Sheets(x).Protect Password:="MyPass"
End If
Next
End Sub
Can someone tell me why, and tell me how to correct it so that it works?
Thanks bunches!!
Ariana