Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Protect cells

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?



  #2   Report Post  
Posted to microsoft.public.excel.programming
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?





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Protect cells

Fernando,

Protect the workbook in a macro, like this:

Sheets(MySheet).Protect UserInterfaceOnly:=True ' Password:="MyPass" '
Password optional.

Or your macro can unprotect the sheet, make its changes, then protect it.
--
Earl Kiosterud
mvpearl omitthisword at verizon period net
-------------------------------------------

"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?





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Protect cells

If I protect the worksheet with a macro, do you I have to unprotect it while
writing, right?

"Earl Kiosterud" wrote in message
...
Fernando,

Protect the workbook in a macro, like this:

Sheets(MySheet).Protect UserInterfaceOnly:=True ' Password:="MyPass" '
Password optional.

Or your macro can unprotect the sheet, make its changes, then protect it.
--
Earl Kiosterud
mvpearl omitthisword at verizon period net
-------------------------------------------

"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?







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
protect cells in excel, but also allow a search in those cells? LindaAlex Excel Worksheet Functions 2 January 28th 10 02:51 PM
How do I protect cells or a range of cells in excel spreadsheet? Abundance Excel Worksheet Functions 1 July 28th 09 11:03 PM
Protect Only Certain Cells bgcooker Excel Discussion (Misc queries) 2 March 25th 09 03:38 PM
Protect cells Tag1948 Excel Worksheet Functions 2 September 3rd 08 05:36 PM
Protect cells Dave Excel Discussion (Misc queries) 1 June 16th 05 09:30 PM


All times are GMT +1. The time now is 05:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"