justagrunt
Technical User
- Oct 10, 2002
- 132
Hi,
I am using the following code to disable a worksheet so
that people cannot tamper with data on it, as it is used
in formulas else where on the sheet, but allows them to
enter data in allocated cells which is then worked on to
give a result. The trouble is It doesn’t seem to work.
The cells can that are supposed to be locked out can still be modified.
Option Explicit
Private module
Sub auto_open()
'when the workbook opens the worksheet(1) is protected
'existing data and formulii are not allowed to be changed
'only certain cell can be altered to allow data entry
'all remaining worksheets are hidden
Worksheets(1).Visible = True
Worksheets(1).Activate
ActiveSheet.Unprotect
ActiveSheet.Range("b3:b4").Locked = False 'data entry cells
ActiveSheet.Range("b6").Locked = False ' data entry
ActiveSheet.Range("f7").Locked = False ' variable entry
ActiveSheet.Protect
Worksheets(2).Visible = False
Worksheets(3).Visible = False
Worksheets(4).Visible = False
Worksheets(5).Visible = False
Worksheets(6).Visible = False
Worksheets(7).Visible = False
Worksheets(8).Visible = False
MsgBox "ok to here", vbOKOnly
End Sub
Regards
Bill
I am using the following code to disable a worksheet so
that people cannot tamper with data on it, as it is used
in formulas else where on the sheet, but allows them to
enter data in allocated cells which is then worked on to
give a result. The trouble is It doesn’t seem to work.
The cells can that are supposed to be locked out can still be modified.
Option Explicit
Private module
Sub auto_open()
'when the workbook opens the worksheet(1) is protected
'existing data and formulii are not allowed to be changed
'only certain cell can be altered to allow data entry
'all remaining worksheets are hidden
Worksheets(1).Visible = True
Worksheets(1).Activate
ActiveSheet.Unprotect
ActiveSheet.Range("b3:b4").Locked = False 'data entry cells
ActiveSheet.Range("b6").Locked = False ' data entry
ActiveSheet.Range("f7").Locked = False ' variable entry
ActiveSheet.Protect
Worksheets(2).Visible = False
Worksheets(3).Visible = False
Worksheets(4).Visible = False
Worksheets(5).Visible = False
Worksheets(6).Visible = False
Worksheets(7).Visible = False
Worksheets(8).Visible = False
MsgBox "ok to here", vbOKOnly
End Sub
Regards
Bill