» Cell protection only for formulas using VBA in Microsoft Excel
CATEGORY - Protecting in VBA
VERSION - All Microsoft Excel Versions
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
Book Store:
Recommended Books:
- The Sweet Potato Queens' Big-Ass Cookbook and Financial Planner
- The Intelligent Investor: The Classic Bestseller on Value Investing
- Cashflow Quadrant: Rich Dad's Guide to Financial Freedom
- The Analysis and Use of Financial Statements
- Successful Business Planning in 30 Days: A Step-By-Step Guide for Writing a Business Plan and Starting Your Own Business
- Microsoft Office XP Step-By-Step (With CD-ROM)
protection of formula
rashid
i am trying to hide formula in cell ,i did check hide and locked.but still i can see formula in formula bar.plz help me out how to protect formula from if i press delete by mistake the formula will be deleted i just want to lock formula cells.
protection
syed atif
how we can protect our only one cell in spreadsheet

