Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Testing CF Conditions

Hi

In a previous question on testing CF conditions I was directed to a website
xldynamic.com/source/xld.cfconditions.html. I need to use the function
listed as IsCFMet but it does not giving me the expected response when using
a formula condition.

As a check I created a condition cell (value is, equal to, 1, pattern red)
in A1 and in B1 used the function. It returned TRUE as expected. However,
the real formulas are more complex and when I entered an example in A2 of
Formula is, =LEN(A2)40, pattern red OR cell value is, equal to,="", pattern
blue the function returns FALSE when the cell is empty (instead of TRUE). If
I enter more than 40 characters to activate the other condition the function
returns TRUE (which is correct).

Is there something wrong with my conditional format or something which needs
changing in the code? I would be grateful for any help on this.

Thanks

G

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Testing CF Conditions

I stepped through the code and when it got to the line:
IsCFMet = rng.Value = oFC.Formula1
rng.Value = Empty, not the same as =""

I changed your 2nd condition to Formula Is: = ISBLANK(A2) = TRUE
and IsCFMet() returned TRUE.

Hth,
Merjet




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Testing CF Conditions

Thanks Merjet but there is still a problem with another condition. This time
as a second condition of I have cell value, is not equal to," "(to represent
a space), green. When I enter a space so that neither condition is met
IsCFMet continues to return a value of TRUE instead of FALSE. I can
understand empty not being the same as "" but not this condition where it is
specifically a space.

Thanks

"merjet" wrote:

I stepped through the code and when it got to the line:
IsCFMet = rng.Value = oFC.Formula1
rng.Value = Empty, not the same as =""

I changed your 2nd condition to Formula Is: = ISBLANK(A2) = TRUE
and IsCFMet() returned TRUE.

Hth,
Merjet





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Testing CF Conditions

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Testing for conditions with IF statement and AND function Joe[_13_] Excel Worksheet Functions 1 February 9th 09 06:07 PM
Countif Conditions - Use of conditions that vary by cell value JonTarg Excel Discussion (Misc queries) 1 May 30th 08 01:21 PM
shade cells based on conditions - i have more than 3 conditions Mo2 Excel Worksheet Functions 3 March 30th 07 07:19 AM
Testing 2 conditions on an IF statement CRayF Excel Programming 4 September 24th 05 11:10 PM
Testing for Multiple Conditions Steve Excel Discussion (Misc queries) 2 July 20th 05 12:29 AM


All times are GMT +1. The time now is 03:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"