How to: text color depend on value

  • Thread starter Thread starter bobsmith58d
  • Start date Start date
B

bobsmith58d

Anyone know how to make the text change colors, depending on what valu
certain data is? I'm sure it's easy...
 
Hi Bob

Her is a chunk of code I use as you will see the relevant part
conditionally colour codes cell values

Range("w6").Select

For r = 1 To 230

For z = 1 To rowl
task = ActiveCell.Value

If Left(task, 1) = ">" Then crt = Mid(task, 2)
If Left(task, 1) = ">" Then ActiveCell.Value = crt
If Left(task, 1) = Chr$(126) Then crt = Mid(task, 2)
If Left(task, 1) = Chr$(126) Then ActiveCell.Value = crt
If task = "Not detected" Then ActiveCell.Value = "N/D"
If task = "n/a" Then ActiveCell.Value = "."
If task = "Listeria Monocytogenes" Then ActiveCell.Value = "L.mono"
If task = "To Follow" Then ActiveCell.Value = "T.F."
If task = "Listeria species not monocytogenes" Then ActiveCell.Value = "List
not mono"
If task = "Positive" Then ActiveCell.Value = "Pos"

Rem grading

If ActiveCell.Comment Is Nothing Then ADVERSE = 1
If ADVERSE = 0 Then ActiveCell.Font.ColorIndex = 5 <<<<<<<<<<<< This what
you want
If ADVERSE = 0 Then ActiveCell.Offset(0, -r).Select
ActiveCell.Offset(0, -21).Select
If ADVERSE = 0 Then ActiveCell.Font.ColorIndex = 5
If ADVERSE = 0 Then ActiveCell.Offset(0, r).Select
ActiveCell.Offset(0, 21).Select
ADVERSE = 0

ActiveCell.Offset(1, 0).Select
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top