0
我有一个代码,将一个单元格数组转换为一个循环的字符串。如果单元格包含特定的字符串,它会正确地将布尔变量放入布尔发现的变量中,但用这些变量作为目标的if语句会被跳过,并且只会执行最后一个else语句。我不知道为什么会这样并且会喜欢关于为什么if语句可能不会将变量视为true的任何输入。提前致谢。布尔和If语句
trimmedValX = Trim$(ur(r, m(6))) *creates the string
Found1 = InStr(trimmedValX, "still sold") *checks to see if string is in the created string, if it is variable is set as True
Found2 = InStr(trimmedValX, "Still sold")
Found3 = InStr(trimmedValX, "Discontinued")
If Found3 = True Then
cell1.Interior.Color = rColor
ElseIf Found1 = True or Found2 = True Then
cell1.Interior.Color = gColor
Else
cell1.Interior.Color = mColor
End If
提出好的建议InStr函数内部消除感谢你,得到了代码为我工作的需要。 – FrenchP