FormatConditions(1).Formula1
Hi Bob,
My question was exactly what you understood! Many thanks for your reply, it
takes some time to understand and apply it, I will let you know the result.
Regards,
Stefi
€˛Bob Phillips€¯ ezt Ć*rta:
If I understand you correctly, you want to know if a cell is meeting its CF
conditions. This is problematical if that cell is not active. This is what I
use
'---------------------------------------------------------------------
Public Function IsCFMet(rng As Range) As Boolean
'---------------------------------------------------------------------
Dim oFC As FormatCondition
Dim sF1 As String
Dim iRow As Long
Dim iColumn As Long
Set rng = rng(1, 1)
If rng.FormatConditions.Count 0 Then
For Each oFC In rng.FormatConditions
If oFC.Type = xlCellValue Then
Select Case oFC.Operator
Case xlEqual
IsCFMet = rng.Value = oFC.Formula1
Case xlNotEqual
IsCFMet = rng.Value < oFC.Formula1
Case xlGreater
IsCFMet = rng.Value oFC.Formula1
Case xlGreaterEqual
IsCFMet = rng.Value = oFC.Formula1
Case xlLess
IsCFMet = rng.Value < oFC.Formula1
Case xlLessEqual
IsCFMet = rng.Value <= oFC.Formula1
IsCFMet = (rng.Value = oFC.Formula1 And _
rng.Value <= oFC.Formula2)
Case xlNotBetween
IsCFMet = (rng.Value < oFC.Formula1 Or _
rng.Value oFC.Formula2)
End Select
Else
're-adjust the formula back to the formula that applies
'to the cell as relative formulae adjust to the activecell
With Application
iRow = rng.Row
iColumn = rng.Column
sF1 = .Substitute(oFC.Formula1, "ROW()", iRow)
sF1 = .Substitute(sF1, "COLUMN()", iColumn)
sF1 = .ConvertFormula(sF1, xlA1, xlR1C1)
sF1 = .ConvertFormula(sF1, xlR1C1, xlA1, , rng)
End With
IsCFMet = rng.Parent.Evaluate(sF1)
End If
If IsCFMet Then Exit Function
Next oFC
End If 'rng.FormatConditions.Count 0
End Function
--
HTH
Bob Phillips
(remove nothere from email address if mailing direct)
"Stefi" wrote in message
...
Hi Bob,
Sorry for my poor English! I'd like to know wether the formula in
ActiveCell.FormatConditions(1).Formula1 gives True or False!
In the meantime I made a solution:
Function FormCondTF(fcformulaLoc, workcell)
Range(workcell).FormulaLocal = fcformulaLoc
FormCondTF = Range(workcell)
Range(workcell).ClearContents
End Function
Answer = FormCondTF(ActiveCell.FormatConditions(1).Formula1 , "Z1")
But I'm still interested in your opinion!
Regards,
Stefi
"Bob Phillips" ezt Ć*rta:
Pardon? What does the question mean?
--
HTH
Bob Phillips
(remove nothere from email address if mailing direct)
"Stefi" wrote in message
...
Hi All,
It is known that
ActiveCell.FormatConditions(1).Formula1
returns the formula as a string.
How can I ask if this formula fulfils for ActiveCell (or another cell)
or
not?
Thanks,
Stefi
|