Am I 'Dim'
I think that with Excel 2002 and later you are allowed more choices
when sheets are protected, but as you are using XL2k you can't make
use of these features. Perhaps your book is written for a later
version and so some of the code won't work.
Hope this helps.
Pete
On Feb 22, 11:04 am, "GrahamB" wrote:
I am using Excel 2000 and have created a workbook with 3 worksheets which I
have tried to protect with the code .
Private Sub Workbook_Open()
'This macro automatically protects the worksheets on opening, allows macros
to run, and allows limited formatting 'before going to the 'Date cell.
Sheets(1).Protect Password:="secret", UserInterfaceOnly:=True
Sheets(2).Protect Password:="secret", AllowInsertingRows:=True,
AllowDeletingRows:=True, AllowSorting:=True
Sheets(3).Protect Password:="secret", AllowInsertingRows:=True,
AllowSorting:=True
It accepts the first line but comes up with 'run-time 1004 error due to App.
or Obj. defined error' somewhere on the line starting 'Sheets(2)'. I'm
trying to teach myself VBA from a book so please be gentle with me if it's a
simple error. GrahamB
|