Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
HasFormula protect cell
Hello wizards,
Below sub works and does not work ...!!! I mean: clicking on a cell that has a formula will "protect" the sheet .... as you can unprotect the sheet. (ToolsProtectionUnprotect) **But** does actually NOT protect at all as I can just overwrite the formula in the cell! Just try and see what I mean... Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) If Target.HasFormula = True Then Me.Protect Password:="" Else Me.Unprotect Password:="" End If End Sub Cheers Sige |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
HasFormula protect cell
Are the cells locked?
-- Vasant "SIGE" wrote in message om... Hello wizards, Below sub works and does not work ...!!! I mean: clicking on a cell that has a formula will "protect" the sheet ... as you can unprotect the sheet. (ToolsProtectionUnprotect) **But** does actually NOT protect at all as I can just overwrite the formula in the cell! Just try and see what I mean... Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) If Target.HasFormula = True Then Me.Protect Password:="" Else Me.Unprotect Password:="" End If End Sub Cheers Sige |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
HasFormula protect cell
It works for me. Once I have entered a formula and I go back to the same
cell, I cannot overwrite the formula. Hope you have not unlocked the cells and they are still locked?! Alok Joshi "SIGE" wrote: Hello wizards, Below sub works and does not work ...!!! I mean: clicking on a cell that has a formula will "protect" the sheet .... as you can unprotect the sheet. (ToolsProtectionUnprotect) **But** does actually NOT protect at all as I can just overwrite the formula in the cell! Just try and see what I mean... Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) If Target.HasFormula = True Then Me.Protect Password:="" Else Me.Unprotect Password:="" End If End Sub Cheers Sige |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
HasFormula protect cell
Is the target cell locked or unlocked? If it is unlocked then protecting the
sheet will have no effect. Try locking all of the formulas. Select the entire sheet then... F5 - Special - Formulas This will select all of the formulas on the sheet. On the Cell format menu select the protection tab and ensure the cells are locked. HTH Jim Thomlinson "SIGE" wrote: Hello wizards, Below sub works and does not work ...!!! I mean: clicking on a cell that has a formula will "protect" the sheet .... as you can unprotect the sheet. (ToolsProtectionUnprotect) **But** does actually NOT protect at all as I can just overwrite the formula in the cell! Just try and see what I mean... Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) If Target.HasFormula = True Then Me.Protect Password:="" Else Me.Unprotect Password:="" End If End Sub Cheers Sige |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
HasFormula protect cell
One more thing that I forgot to mention. Make sure all of the cells you want
the user to be able to modify are unlocked. Otherwise if a user enters a fromula into a cell that is locked, they will not be able to modify it later on... Jim Thomlinson "SIGE" wrote: Hello wizards, Below sub works and does not work ...!!! I mean: clicking on a cell that has a formula will "protect" the sheet .... as you can unprotect the sheet. (ToolsProtectionUnprotect) **But** does actually NOT protect at all as I can just overwrite the formula in the cell! Just try and see what I mean... Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) If Target.HasFormula = True Then Me.Protect Password:="" Else Me.Unprotect Password:="" End If End Sub Cheers Sige |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
HasFormula protect cell
Hi Guys,
You are all right... my target cells are unlocked! But that is actually the whole point. I do NOT want to be locking all my formula cells with: GoToSpecialFormulas... I would like this sub to do that automatically. Lock all Cells containing formulas. I thought this would do it ... Suggestions? Sige "NOSPAM" to be removed for direct mailing... *** Sent via Developersdex http://www.developersdex.com *** |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
HasFormula protect cell
This goes fine ...for my purposes!
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) If Target.HasFormula = True Then Target.Locked = True Me.Protect Password:="" Else Me.Unprotect Password:="" End If End Sub Cheers Sige "NOSPAM" to be removed for direct mailing... *** Sent via Developersdex http://www.developersdex.com *** |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
HasFormula protect cell
Nevertheless some cells get locked and others don't!
Any Ideas? Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) ' On Error Resume Next If Target.Locked = True And CheckBox1 = True Then Me.Protect Password:="" Else If Target.HasFormula = True And CheckBox1 = True Then On Error GoTo err: Target.Locked = True '<<=*=*=*=*=*=* Me.Protect Password:="" Else Me.Unprotect Password:="" End If End If err: End Sub Sige "NOSPAM" to be removed for direct mailing... *** Sent via Developersdex http://www.developersdex.com *** |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Protect or Unprotect Cell dependent on different cell | Excel Discussion (Misc queries) | |||
Is it possible to protect cell formatting in an unlocked cell? | Excel Discussion (Misc queries) | |||
EXCEL: Protect a cell depending on another cell value | Excel Worksheet Functions | |||
Protect Cell | Excel Worksheet Functions | |||
protect specific cell but allow edit on other cell | Excel Worksheet Functions |