mardi 5 septembre 2017

Boolean and If statement

I have a code that converts an array of cells into strings across a loop. It correctly puts trues in the boolean found variables if the cell contains the specific string, but the if statements that are targeted with those variables true are skipped and only the very last else statement is preformed. I am not sure why this would be and would love any input as to why the if statement might not be seeing the variable as true. Thanks in advance.

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

Aucun commentaire:

Enregistrer un commentaire