View Single Post
  #24   Report Post  
Posted to microsoft.public.excel.misc
ktykerr ktykerr is offline
external usenet poster
 
Posts: 4
Default Can I protect all excel tabs in a file with one password entry

Hi Dave,
I tried it and it's working. Thank you for all the help.
Sorry for the late reply i can't send my post last time since the page is
prompting 'service is temprary not available'.
Thanks again.

"Dave Peterson" wrote:

Move the code to a general module
Insert|Module
and try it again.

You can protect your code by (inside the VBE):
Tools|VBAProject Properties|Protection tab
give it a memorable password.

Save and close your file and reopen it to test.



ktykerr wrote:

Hi Dave,
Thanks for the quick reply.
I've put the code under the "thisworkbook" workbook alone.
I just ran the first macro and there were no errors.

After submitting my first post, I learned that the first sheet is protected
because I cannot touch/edit the data on the 1st worksheet itself. While on
the other worksheets I can still edit the data inside the cell that's why I'm
wondering.
I tried experimenting by deleting data on the next worksheets and after
pressing the âœEnter❠key it does prompted a message that the worksheet is
protected as well. So the code is working properly.
However, my next problem is that...after sharing the protected file the
users can âœaccess/view❠and âœsave as❠the file as read only. After they have
saved the file as read only they were able to open/view the code through
Macro-Visual Basic Editor in effect they now can see the password.

Is there any way I can hide the macro code so that they wonât have access on
the password?
Also, is that a normal result that only the first sheet is fully protected
while you can still click and edit data the cells of the other worksheets?

"Dave Peterson" wrote:

Did you put the code in the same workbook as the worksheets to protect?

Did you only run the first macro?

Were there any errors when you ran it?

ktykerr wrote:

Hi, I'm trying to run this macro code in my excel file since I also need and
wanted to protect several sheets at a time. However, after running it, only
the first sheet was protected and the rest is still unprotected.
Can anyone help me on this please? Thanks in advance.

"Jen@ccbcc" wrote:

Sub Protect_All_Sheets()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Protect Password:="123"
Next ws
End Sub

Sub Unprotect_All_Sheets()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Unprotect Password:="123"
Next ws
End Sub

Each time I attempt to run the unprotect macro, I receive an error which
points to the line "ws.Unprotect Password:="123"

"Dave Peterson" wrote:

If you protect the sheets without supplying a password, then the code won't need
to use a password, either.

But if you use a password manually, you'll need it in code, too.

I think you made a typo when you made that suggested change.

Post your current code and indicate the line that caused the error.

Jen@ccbcc wrote:

If I simply replace the protect with unprotect, I receive the following error
message:

Compile error: Expected function or variable

Also...is there a way to perform these macros without requiring a password?

"Dave Peterson" wrote:

Just use

ws.unprotect password:="123"

to unprotect the sheets. They all share the same password, right?

Jen@ccbcc wrote:

Does anyone know how to do the reverse (i.e. unprotect all sheets at once)?

"Paul B" wrote:

Indiana, you can use a macro like this,

Sub protect_sheets()

Dim ws As Worksheet

For Each ws In ThisWorkbook.Worksheets

ws.Protect password:="123"

Next ws

End Sub
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003


"Indiana born" <Indiana wrote in message
...
I have spreadsheets with multiple tabs - I presently have to password
protect
each tab separately. I'm looking for a way to protect all tabs with one
password entry. i am not share the files, but others do view them and I
don't want changes made.




--

Dave Peterson


--

Dave Peterson


--

Dave Peterson


--

Dave Peterson