Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5
Default protecting and unprotecting

I googled the group before posting, but I wasn't able to make any use
of what I found (my VBA-fu is still pretty feeble). Anyway, I was
wondering how to do the following:

I would like to protect cell B1 if value in A1 is lesser than 10.

thanks
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default protecting and unprotecting

By default, all cells are LOCKED. Right click on the cellformat
cellsprotection to see this. So, If you want all UN protectedselect cells
by selecting the box to the left of the column letters and above the row
headers and unlock all then you can use code to lock the cell and then
protect the sheet.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Fusion1337" wrote in message
...
I googled the group before posting, but I wasn't able to make any use
of what I found (my VBA-fu is still pretty feeble). Anyway, I was
wondering how to do the following:

I would like to protect cell B1 if value in A1 is lesser than 10.

thanks


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5
Default protecting and unprotecting

On Sep 25, 7:59*pm, "Don Guillett" wrote:
By default, all cells are LOCKED. Right click on the cellformat
cellsprotection to see this. So, If you want all UN protectedselect cells
by selecting the box to the left of the column letters and above the row
headers and unlock all then you can use code to lock the cell and then
protect the sheet.


Hey Don

I'm sorry I phrased the question wrongly. Basically I would like to
protect cell B1 from any kind of access or editing unless value in A1
is greater than 10.
So presumably I would have to unlock A1 and protect the sheet,
followed by the code to unlock B1 if the conditions in A1 are met.
What would the code be?

thanks
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default protecting and unprotecting

When dealing with me, always answer at the TOP

Manually do as I suggested earlier to unlock a1 and protect the worksheet.
Then, right click sheet tabview codecopy/paste thischange pw to suitSave
the workbook
Now, if a1 is 10 or more b1 will be unprotected.

Private Sub Worksheet_Change(ByVal target As Range)
If Intersect(target, Range("a1")) Is Nothing Then Exit Sub
'MsgBox "HI"
If target 10 Then
ActiveSheet.Unprotect Password:="pw"
Range("b1").Locked = False
ActiveSheet.Protect Password:="pw"
Else
ActiveSheet.Unprotect Password:="pw"
Range("b1").Locked = True
ActiveSheet.Protect Password:="pw"
End If
End Sub



--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Fusion1337" wrote in message
...
On Sep 25, 7:59 pm, "Don Guillett" wrote:
By default, all cells are LOCKED. Right click on the cellformat
cellsprotection to see this. So, If you want all UN protectedselect
cells
by selecting the box to the left of the column letters and above the row
headers and unlock all then you can use code to lock the cell and then
protect the sheet.


Hey Don

I'm sorry I phrased the question wrongly. Basically I would like to
protect cell B1 from any kind of access or editing unless value in A1
is greater than 10.
So presumably I would have to unlock A1 and protect the sheet,
followed by the code to unlock B1 if the conditions in A1 are met.
What would the code be?

thanks

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5
Default protecting and unprotecting

Thanks, that worked nicely

Private Sub Worksheet_Change(ByVal target As Range)
If Intersect(target, Range("a1")) Is Nothing Then Exit Sub
'MsgBox "HI"
If target 10 Then
ActiveSheet.Unprotect Password:="pw"
Range("b1").Locked = False
ActiveSheet.Protect Password:="pw"
Else
ActiveSheet.Unprotect Password:="pw"
Range("b1").Locked = True
ActiveSheet.Protect Password:="pw"
End If
End Sub



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
Protecting and Unprotecting several worksheets at one time Learning Excel Excel Discussion (Misc queries) 8 February 4th 09 10:07 PM
Unprotecting a worksheet Jessica Excel Worksheet Functions 8 August 21st 08 06:43 PM
Macro for protecting and unprotecting multiple worksheets saltnsnails Excel Discussion (Misc queries) 7 January 24th 08 10:49 PM
Unprotecting a Sheet SergioCorreiaMaputo Excel Discussion (Misc queries) 3 June 20th 06 10:56 AM
PROTECTING/UNPROTECTING SHEETS Maureen Excel Discussion (Misc queries) 1 January 6th 05 06:46 PM


All times are GMT +1. The time now is 08:33 AM.

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"