View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
incre-d[_2_] incre-d[_2_] is offline
external usenet poster
 
Posts: 14
Default Locking cells using VBA based on other cell values

1) Cells are automatically locked by default, but you have to protect the
workbook to make the locking work.

2) You start off with all cells locked and the worksheet unprotected.

To answer your question

theSheet.unprotect
Range("9:400").locked = true
theSheet.protect

"Evil Red Smurf" wrote:

Hi,
I'm trying to lock cells in a column on an excel spreadsheet depending on
the (date) value in another cell on the same row. For example, I'm thinking
of it like this:
If range("C9").value today()
Then range("G9").lock = false
Else range("G9").lock = true
End if

However I want to do it for all rows between 9 and 400 whenever the sheet is
accessed. Can anyone help?

Many thanks,