Thread: Protect cells
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
TroyW[_2_] TroyW[_2_] is offline
external usenet poster
 
Posts: 94
Default Protect cells

Fernando,

Below is some simple code that will work in any version. This is one
approach to take.
1) Unprotect the sheet; 2) make your changes; 3) Protect the sheet.

You don't say which version of Excel you will be using. The newer versions
have additional features for the Protection command. Search the Excel Visual
Basic Help for "Protect Method" for more details (UserInterfaceOnly may be
of interest to you also).

Troy


Sub Test1()
'''Unprotect the sheet.
ActiveSheet.Unprotect

'''Your code to make changes.
ActiveSheet.Range("A1").Value = "Hello"
'''...

'''Protect the sheet.
ActiveSheet.Protect
End Sub


"Fernando Duran" wrote in message
. ..
I'm trying to write in a worksheet using a macro, I have no problem, as

long
the worksheet isn't protect. But I want to protect the file, so, the user
wont be able to change anything.. can I get some help in this problem?