ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Automatically lock cells and hide formulas (https://www.excelbanter.com/excel-programming/318983-automatically-lock-cells-hide-formulas.html)

Qaspec

Automatically lock cells and hide formulas
 
I'd like to set the cell format properties to "lock" and "hide" any formulas
entered into the cells and protect each sheet when my workbook is opened.

Nick Hodge

Automatically lock cells and hide formulas
 
Something like the code below in the Workbook_open() event will do

Private Sub Workbook_Open()
Dim wks As Worksheet
For Each wks In Me.Worksheets
With wks
.Cells.Locked = True
.Cells.FormulaHidden = True
.Protect Password:="abcd"
End With
Next wks
End Sub


--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"Qaspec" wrote in message
...
I'd like to set the cell format properties to "lock" and "hide" any
formulas
entered into the cells and protect each sheet when my workbook is opened.




Don Guillett[_4_]

Automatically lock cells and hide formulas
 
Look in help index for protection and then
Password protect a worksheet or workbook

--
Don Guillett
SalesAid Software

"Qaspec" wrote in message
...
I'd like to set the cell format properties to "lock" and "hide" any

formulas
entered into the cells and protect each sheet when my workbook is opened.




Qaspec

Automatically lock cells and hide formulas
 
Thanks....my only problem is that this locks all cells. I would like to only
lock cells that contain formulas. If possible.

"Nick Hodge" wrote:

Something like the code below in the Workbook_open() event will do

Private Sub Workbook_Open()
Dim wks As Worksheet
For Each wks In Me.Worksheets
With wks
.Cells.Locked = True
.Cells.FormulaHidden = True
.Protect Password:="abcd"
End With
Next wks
End Sub


--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"Qaspec" wrote in message
...
I'd like to set the cell format properties to "lock" and "hide" any
formulas
entered into the cells and protect each sheet when my workbook is opened.





Don Guillett[_4_]

Automatically lock cells and hide formulas
 
for each c in selection
if c.hasformula then
next c

--
Don Guillett
SalesAid Software

"Qaspec" wrote in message
...
Thanks....my only problem is that this locks all cells. I would like to

only
lock cells that contain formulas. If possible.

"Nick Hodge" wrote:

Something like the code below in the Workbook_open() event will do

Private Sub Workbook_Open()
Dim wks As Worksheet
For Each wks In Me.Worksheets
With wks
.Cells.Locked = True
.Cells.FormulaHidden = True
.Protect Password:="abcd"
End With
Next wks
End Sub


--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"Qaspec" wrote in message
...
I'd like to set the cell format properties to "lock" and "hide" any
formulas
entered into the cells and protect each sheet when my workbook is

opened.







All times are GMT +1. The time now is 01:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com