Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Protect formulas but still allow formatting, etc.?

I'm trying to protect all the cells in a spreadsheet with formulas in
them (don't mind the user seeing the formulas, just don't want him
changing them), have done so using the following code (compliments of
this group, thanks!):

Sub lock_cells()
Set mySheets = ActiveWorkbook.Sheets
For Each s In mySheets
If s.Name < "Information Summary" Then
s.Activate
ActiveSheet.Unprotect
Cells.Locked = False
Selection.SpecialCells(xlCellTypeFormulas, 23).Locked =True
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
End If
Next s
End Sub

Problem is, some functionality goes away -- e.g., I have some sheets
where I have grouped rows/columns, and once the sheet is protected the
user cannot collapse/expand these groups. Also, on a protected sheet
the user cannot change any formatting -- can't bold or indent, change
column width or font color/size, etc.

Is there a way to simply lock only the cells with formulas but still
allow the user to do anything else on the sheet(s)? Something like
lock the cells without protecting the sheet?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Protect formulas but still allow formatting, etc.?

For the outlining, from help on EnableOutlining

EnableOutlining Property
True if outlining symbols are enabled when user-interface-only protection is
turned on. Read/write Boolean.
Remarks
This property applies to each worksheet and isn't saved with the worksheet
or session.

Example
This example enables outlining symbols on a protected worksheet.

ActiveSheet.EnableOutlining = True
ActiveSheet.Protect contents:=True, userInterfaceOnly:=True
-- Regards,Tom Ogilvy "Steve" wrote in message
ups.com...
I'm trying to protect all the cells in a spreadsheet with formulas in
them (don't mind the user seeing the formulas, just don't want him
changing them), have done so using the following code (compliments of
this group, thanks!):

Sub lock_cells()
Set mySheets = ActiveWorkbook.Sheets
For Each s In mySheets
If s.Name < "Information Summary" Then
s.Activate
ActiveSheet.Unprotect
Cells.Locked = False
Selection.SpecialCells(xlCellTypeFormulas, 23).Locked =True
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
End If
Next s
End Sub

Problem is, some functionality goes away -- e.g., I have some sheets
where I have grouped rows/columns, and once the sheet is protected the
user cannot collapse/expand these groups. Also, on a protected sheet
the user cannot change any formatting -- can't bold or indent, change
column width or font color/size, etc.

Is there a way to simply lock only the cells with formulas but still
allow the user to do anything else on the sheet(s)? Something like
lock the cells without protecting the sheet?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Protect formulas but still allow formatting, etc.?

Beautiful, Tom. Thanks.

I suppose as far as being able to do simple format changes (bold an
entry, indent a cell, change font color, etc.) I am still out of luck?
I've done more searching in this group and it appears that besides the
Data Validation option that some have mentioned (and which I do not
want to use b/c of its shortcomings), I am stuck with all the other
limitations.

If anyone knows of other code solutions similar to what Tom just
suggested Outlining, I'd much appreciate it.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Protect formulas but still allow formatting, etc.?

If you have Excel 2002 or later, you have a lot more options with sheet
protection. Of couse if someone using the workbook will have an older
workbook or your version is older, then that doesn't help much.

These are some of the options found under worksheet level protection in
those newer versions:

expression.Protect(Password, DrawingObjects, Contents, Scenarios,
UserInterfaceOnly, AllowFormattingCells, AllowFormattingColumns,
AllowFormattingRows, AllowInsertingColumns, AllowInsertingRows,
AllowInsertingHyperlinks, AllowDeletingColumns, AllowDeletingRows,
AllowSorting, AllowFiltering, AllowUsingPivotTables)

--
Regards,
Tom Ogilvy


"Steve" wrote in message
oups.com...
Beautiful, Tom. Thanks.

I suppose as far as being able to do simple format changes (bold an
entry, indent a cell, change font color, etc.) I am still out of luck?
I've done more searching in this group and it appears that besides the
Data Validation option that some have mentioned (and which I do not
want to use b/c of its shortcomings), I am stuck with all the other
limitations.

If anyone knows of other code solutions similar to what Tom just
suggested Outlining, I'd much appreciate it.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Protect formulas but still allow formatting, etc.?

Thanks a million! Haven't tried them yet, but if I'm interpreting
correctly it looks like I'll be able to do most if not all that I want.
You rock.



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 Cell Formatting including Conditional Formatting Mick Jennings Excel Discussion (Misc queries) 5 November 13th 07 05:32 PM
Protect my formulas! VegasBurger Excel Worksheet Functions 4 June 14th 06 09:25 PM
Protect Formulas parteegolfer Excel Worksheet Functions 1 March 25th 06 02:09 AM
how to protect formulas in a cell Enrique Mahecha Excel Discussion (Misc queries) 4 December 27th 05 07:34 AM
protect formulas Todd[_6_] Excel Programming 3 September 10th 03 10:15 PM


All times are GMT +1. The time now is 12:26 PM.

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"