View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
KD[_5_] KD[_5_] is offline
external usenet poster
 
Posts: 17
Default Logical operator inconsistency

Hi All:
I am conditional formatting a userform label based on whether a
calculated value is greater than a number assigned to a State. The
assigned number is retrieved in a vlookup. Green if
lLastScoreCutLine, red if false. Named Range lLastScore is the
calculated field and Named Range Cutline is the State value.
Unfortunately the rest of the code is too long for me too post so it
will not work if you cut and paste.

Me.lCutLine.Caption = ThisWorkbook.Worksheets("Input
Form").Range("CutLine").Text

Me.lLastScore.Caption = ThisWorkbook.Worksheets("Prioritization
Output").Range("Score").Text
If Me.lLastScore.Caption Me.lCutLine.Caption Then
Me.lLastScore.ForeColor = &HC000&
Else
Me.lLastScore.ForeColor = &HFF&
End If

If Me.lLastScore.Caption Me.lCutLine.Caption Then
Me.Label61.ForeColor = &HC000&
Else
Me.Label61.ForeColor = &HFF&
End If

The code does not throw an error, but it is inconsistent. It works for
Colorado, but not for Texas and New Mexico. I have double checked
lookup table formatting and they table is consistent all #.00 number.
They evaluate at:

CutLine (Colorado)="1.94"
CutLine (Texas)="3.65"
lLastScore="12.2" or "1.1" or "3.9" or "100.6"

The quotes indicate they are coming in as strings. Can I bring them in
as numeric values? The .Value property does not work.

Thanks. This has me stumped.......

James