Conditional formatting

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

Is there a chance to bind 6 conditions to a textfield.

For instance, if "X field" values are:

0 to 15 = 1 (white)
16 to 30 = 2 (grey)
31 to 45 = 3 (red)
46 to 60 = 4 (yellow)
61 to 75 = 5 (orange)
76 to 100 = 6 (green)



Thanks,
Tom
 
Tom said:
Is there a chance to bind 6 conditions to a textfield.

For instance, if "X field" values are:

0 to 15 = 1 (white)
16 to 30 = 2 (grey)
31 to 45 = 3 (red)
46 to 60 = 4 (yellow)
61 to 75 = 5 (orange)
76 to 100 = 6 (green)



Thanks,
Tom
I think Conditional Formatting only lets you use 3 choices. You'll have
to do it in VBA, but you could probably do it easily with switch. For
example:

Private Sub X_AfterUpdate()
Dim Grey, Orange As Long
Grey = 12632256
Orange = 39423

X.BackColor = Switch(X < 16, vbWhite, X < 31, Grey, X < 46, vbRed, _
X < 61, vbYellow, X < 76, Orange, _
X > 75, vbGreen)
End Sub

Note that this sets the field to green for all values above 75, so if
your bounds-checking isn't good, 158 would also be green.

grep
 
Back
Top