valueListItems returns a list of all values in the value list. Since you have multiple items on the list, comparing a single name to the entire list fails even if it is somewhere in that list due to the other values in the list.
Say you have this list in "drain/toss": Sodium Chloride, Sucrose
IF you have "Sucrose" in Chem1Name, your expression is evaluating as:
If ["Sucrose" = "Sodium Chloride <ReturnCharacter>Sucrose"]
and this is false.
Use this expression:
Valuecount ( FilterValues ( ValueLISTItems (Get ( FileName ) ; "DRAIN/TOSS") ; Waste tags::Chem1Name ) )
If any of these functions are unfamiliar, you can look them up in help to see how and why they work here.
And in most cases, I'd use this in a conditional format expression instead of in a script, but you may have good reason for changing the actual data by adding the blue formatting data to it.
i gota say, you are awsome!
thank you so much for all your help and advice!