Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Logical operator inconsistency

James,
You are comparing strings, not their numerical value. Hence "12" < "2"
because "1" < "2" .
If you mean to compare their numeric value, do CSng(Me.lLastScore.Caption)
etc.

NickHK

"KD" wrote in message
oups.com...
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



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
Using cell reference with logical operator in DGET expression BoxleyFarm Excel Worksheet Functions 1 April 28th 10 11:31 AM
Change Boolean / Logical Operator using Input Cell Sam via OfficeKB.com Excel Worksheet Functions 2 May 1st 08 06:18 PM
Logical operator in Calculated Field Formula Fatih Can1968[_2_] Excel Discussion (Misc queries) 4 July 11th 07 06:04 PM
LOGICAL OPERATOR "IF" FOR AN ARRAY FARAZ QURESHI Excel Discussion (Misc queries) 5 January 21st 07 08:35 PM
Excel logical operator for a cell if another cell has a certain co jerryhuyghe Excel Programming 1 November 6th 04 08:05 PM


All times are GMT +1. The time now is 12:20 PM.

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

About Us

"It's about Microsoft Excel"