@ Mahaveer
Hi
Sorry for my late replay, just i was went for some days on PONGAL leaves
good point out and when you press the short cut key or insert row then the formula is display due to we use the range option
when we insert the cell or row then the formula column is out of range and it's display the formula
if you can change the code as
Set Rng = Range("A1:A20, E1:E20, H1:H20")
changed code is
Set Rng = Range("A:A, E:E, H:H")
with the change option, when you insert the row or cell then we get the Value not formula of that cell and the formula is not working for that row and when we replace the cell in same place then it's continuing his work
next i have another code which is protect the formula column, i mean in the active sheet cell has a formula then it's protect the sheet and hide the formula if there is no formula then it's release the cell from protect try this
place the code is this work book
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Dim rFormulaCheck As Range
On Error Resume Next
Sh.Unprotect Password:="Secret"
With Selection
.Locked = False
.FormulaHidden = False
End With
If Target.Cells.Count = 1 Then
If Target.HasFormula Then
With Target
.Locked = True
.FormulaHidden = True
End With
Sh.Protect Password:="Secret", UserInterFaceOnly:=True
End If
ElseIf Target.Cells.Count > 1 Then
Set rFormulaCheck = Selection.SpecialCells(xlCellTypeFormulas)
If Not rFormulaCheck Is Nothing Then
With Selection.SpecialCells(xlCellTypeFormulas)
.Locked = True
.FormulaHidden = True
End With
Sh.Protect Password:="Secret", UserInterFaceOnly:=True
End If
End If
On Error GoTo 0
End Sub
Thanks for your point out
Keep watching
SP