Using VBA to Unlock Cells
I have the following code when my workbook opens:
Public Sub Workbook_Open()
ThisWorkbook.Sheets(3).Range("L4").Value = NextSeqNumber
ThisWorkbook.Sheets(3).Range("data1").Value = Date
With Sheet3
'Unlock cells for data entry
[E12:E15, G14, I14, L13:L15, K14:K15, D18:K34, G37:G38, D37:D39,
E40:E41, F42].Locked = False
.Protect 'Protect worksheet
End With
End Sub
The sequential number and date do work because I had that code working
before adding the code to unlock the cells noted and protect the rest of the
worksheet from being changed.
When I open it, I get the following message:
Run time error 1004 Unable to set the Locked property of the Range class.
This is a template file if that would make any difference. There are some
named cell references in this worksheet but none of them are called "class".
I'm using Excel 2003 SP1 on Windows XP SP2.
Thanks for any insight.
Marcia
|