Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 63
Default A cell's value renders a workbook read-only

Can a workbook be rendered "read-only" if Sheet1, A1 returns a value of
1 (A1=1)? In like manner, can the workbook return to normal use if the
cell's value is changed to 0 (A1=0)? Indeed, can the cell's value even
be changed to 0 if the workbook is "read-only"? If it can, let's
assume an entry in B1 of any value greater than 0 will cause A1=0.
Thanks.

Michael

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,696
Default A cell's value renders a workbook read-only

OK, Here's what you can do.

Go to Visual Basic
Tools - Macro - Visual Basic Editor

And create the following:

Sub Macro1()
'
' Macro1
'

'
If (Range("A1") = 1) Then
Range("A1").Select
Selection.Locked = False
Selection.FormulaHidden = False
ActiveWorkbook.Protect Structu=True, Windows:=False
ElseIf (Range("A1") = 2) Then
ActiveWorkbook.Unprotect
End If
End Sub

This will lock the worksheet, but allow you to still edit cell A1.

Now, create a box from your rawing toolbar. Right-click on the box, and
click Assign Macro...

Assign Macro 1 to the box.

Now, when you make cell A1 1, click on the box, and your sheet will be
protected. Change A1 to 2 and click on the box, your sheet will be
unprotected.

Hope this helps...

" wrote:

Can a workbook be rendered "read-only" if Sheet1, A1 returns a value of
1 (A1=1)? In like manner, can the workbook return to normal use if the
cell's value is changed to 0 (A1=0)? Indeed, can the cell's value even
be changed to 0 if the workbook is "read-only"? If it can, let's
assume an entry in B1 of any value greater than 0 will cause A1=0.
Thanks.

Michael


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 63
Default A cell's value renders a workbook read-only

Sean,

Is it possible to place the elements of this macro within the already
existing macro I am using in Sheet1 by pasting the range under Private
Sub... as follows?

Private Sub Worksheet_Change(ByVal TargetCell As Range)
If (Range("A1") = 1) Then
Range("A1").Select
Selection.Locked = False
Selection.FormulaHidden = False
ActiveWorkbook.Protect Structu=True, Windows:=False
ElseIf (Range("A1") = 2) Then
ActiveWorkbook.Unprotect
End If
End Sub

Also, if possible, I need to avoid the use of a button to execute the
macro. Perhaps the macro can be executed as an entry is entered in the
worksheet. Can this work?

Michael

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,696
Default A cell's value renders a workbook read-only

Your programming idea does work. Of course, assuming you enter either 1 or 2
in the cell. Anything else will cause the workbook to retain either it's
protected or unprotected state.

If you right-click on cell A1, select format cells... click on Protection
tab and uncheck Locked, this cell will be changeable even when the workbook
is protected. Thus, no need for the button.

" wrote:

Sean,

Is it possible to place the elements of this macro within the already
existing macro I am using in Sheet1 by pasting the range under Private
Sub... as follows?

Private Sub Worksheet_Change(ByVal TargetCell As Range)
If (Range("A1") = 1) Then
Range("A1").Select
Selection.Locked = False
Selection.FormulaHidden = False
ActiveWorkbook.Protect Structu=True, Windows:=False
ElseIf (Range("A1") = 2) Then
ActiveWorkbook.Unprotect
End If
End Sub

Also, if possible, I need to avoid the use of a button to execute the
macro. Perhaps the macro can be executed as an entry is entered in the
worksheet. Can this work?

Michael


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
HOW DO I SUM TWO CELLS FROM ONE WORKBOOK TO ANOTHER WORKBOOK? Bill O'Neal Excel Worksheet Functions 8 August 14th 09 11:36 PM
Updating linked cells within a workbook, from worksheet to workshe notloiseweiss Excel Discussion (Misc queries) 7 February 18th 08 01:15 AM
Read list of cells; conditional asianmike Excel Discussion (Misc queries) 2 February 1st 06 05:04 PM
Read Only_Protected Workbook? ftjjk Excel Discussion (Misc queries) 4 December 2nd 05 03:43 AM
How do I save an Excel workbook so that cells referencing another. williejoeshaver Excel Discussion (Misc queries) 1 March 11th 05 09:44 PM


All times are GMT +1. The time now is 04:30 PM.

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

About Us

"It's about Microsoft Excel"