Testing CF Conditions
Hi Merjet
Thanks. I used the Code(32) route but when I tried the amended code the
result would not change from TRUE when the field was blank (and a condition
activate) to FALSE when I entered a character (and no condition active). If
it is possible to correct this it could be very useful in case I need to test
for specific text strings on another project although the use of Char(32) is
OK in this instance.
G
"merjet" wrote:
I got IsCFMet to return True by testing for
Formula Is = CODE(32). However, I think you
did find a bug -- testing for any text such as
"xxx". The following is a way to fix the bug.
Dim vX as Variant
If oFC.Type = xlCellValue Then
vX = rng.Value
If Application.IsText(vX) Then _
vX = "=" & Chr(4) & vX & Chr(4)
Select Case oFC.Operator
Case xlEqual
IsCFMet = vX = oFC.Formula1
Case xlNotEqual
IsCFMet = vX < oFC.Formula1
Case xlGreater
IsCFMet = vX oFC.Formula1
Case xlGreaterEqual
IsCFMet = vX = oFC.Formula1
Case xlLess
IsCFMet = vX < oFC.Formula1
Case xlLessEqual
IsCFMet = vX <= oFC.Formula1
IsCFMet = (vX = oFC.Formula1 And _
vX <= oFC.Formula2)
Case xlNotBetween
IsCFMet = (vX < oFC.Formula1 Or _
vX oFC.Formula2)
End Select
Else
Hth,
Merjet
|