protection macro

  • Thread starter Thread starter maryamroz66
  • Start date Start date
M

maryamroz66

Hi,

I am currently working on a project and I need to create a macro that
will only protect (lock) the cells which contain formulas and also the
formating of the worksheet. This is so no one can change a formula or
say for instance the color of a cell, but can input into certain areas
that are not formula driven. PLS HELP! I am new at creating macro and
have only created a personal macro that unprotects worksheets. Thanks
A LOT!

Mimi
 
Why do you need a macro?

You can do that without.

By default all cells are locked when the sheet is protected.

Select the user-entry cells and unlock those then protect the worksheet.

You could use the macro recorder whilst doing the above.


Gord Dibben MS Excel MVP
 
This gets painful when the cells to be protected are few and the entry cells
are many.

in some earlier spreadsheet solutions one could protect selected cells
instead of this round about way.
 
If I understand your statement then the solution seems to be obvious. UNlock
all cells and LOCK those desired. Then protect. A macro could do this for
you.
 
As Don suggests just reverse the process to unlock all cells then select the
ones to lock.

Or run this macro.

Sub lock_formulas()
ActiveSheet.Cells.Locked = False
For Each cell In ActiveSheet.UsedRange
If cell.HasFormula Then
cell.Locked = True
End If
Next
ActiveSheet.Protect Password:="password"
End Sub


Gord

On Mon, 8 Sep 2008 17:16:08 -0700, a m spock <a m
 
Back
Top