|  

» Cell protection only for formulas using VBA in Microsoft Excel

Question:
Only cells with formulas are to be protected. New entries are recognized and also protected.


Answer:
Insert the following code in This Workbook module.









Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rng As Range
For Each rng In Target.Cells
If rng.HasFormula Then
ActiveSheet.Protect
Exit Sub
Else
ActiveSheet.Unprotect
End If
Next rng
End Sub

Rate This Tip
12 34 5
Rating: 2.73     Views: 32599
No comments have been submitted.
Click here to post comment
For Registered Users
Name
Comment Title
Comments