Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 318
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default 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
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 or Unprotect Cell dependent on different cell David Bruce Excel Discussion (Misc queries) 2 March 26th 10 02:19 PM
Is it possible to protect cell formatting in an unlocked cell? Robotbird Excel Discussion (Misc queries) 2 August 25th 09 01:38 PM
EXCEL: Protect a cell depending on another cell value frenchflo Excel Worksheet Functions 1 October 11th 06 05:36 PM
Protect Cell Steven Excel Worksheet Functions 1 January 21st 06 06:37 PM
protect specific cell but allow edit on other cell chiuinggum Excel Worksheet Functions 5 December 8th 05 06:22 PM


All times are GMT +1. The time now is 01:34 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"