Hi, I was wondering if I could get hint regarding following part of my code.
Objective: I have a function that checks if a cell has formula or not. I call it in sub for setting conditional formatting rule. Idea is if anytime user messes with the cell that has formula I throw a red flag (comment) and color code change to indicate that some action was taken. I am stuck at line Formula1:="=""EstFormula(Range(""$" & "J" & "$" & p & "))=False""" where I am setting the conditional format rule. I would appreciate help and probably a better way to do it in case there is one.
Thanks for help
Arjun
Function EstFormula(rng As Range) As Boolean
EstFormula = 0
If rng.HasFormula = True Then
EstFormula = 1
'do nothing
Else
EstFormula = 0
rng.AddComment
rng.Comment.Text Text:="Value edited manually"
End If
End Function
Private Sub Cell_format()
Dim p As Integer
p = 3
Do While ActiveSheet.Range("J" & p) <> Empty
ActiveSheet.Range("J" & p).Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=""EstFormula(Range(""$" & "J" & "$" & p & "))=0"""
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 49407
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
p = p + 1
Loop
End Sub
Bookmarks