Password in a macro

T

T

This is what I am trying to accomplish, however I get an
error when the macro hits password. I want my macro to
lock all the worksheets in an excel file when I run it.

ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True, Password:=xxxx, Password:=xxxx
 
N

Norman Harker

Hi T!

Try:

For j = 1 To Worksheets.Count
Worksheets(j).Protect Password:="not4u2see"
Next j
ActiveWorkbook.Protect Structure:=True, Windows:=False,
Password:="not4u2see"


--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top