So I have created multiple arrays that include various info (states, names, etc). Using these arrays, I need to check to see if the values match to a fixed spreadsheet. So doing so for the names array I do within a loop:
If InStr(Worksheets("Import Spreadsheet").Cells(x, 2), Names(c)) > 0 Then......
And it works perfectly fine. But once I now check using the states array it no longer works. For whatever reason excel is not recognizing it as a string (I think). I tested this theory by hard coding an example. I would take an array value that I know should satisfy the if statement on a given cell and it did not work. So:
If InStr(Worksheets("Import Spreadsheet").Cells(1, 4), State(1)) > 0
TO
If InStr(Worksheets("Import Spreadsheet").Cells(1, 4), "TX") > 0
The first statement would not work even though I know State(1)= TX, but the second if statement worked. Any reasons this might be happening? Both arrays were initialized and filled the same way
EDIT: This is how the arrays are populated within a for loop:
ElseIf IsEmpty(Cells(i + 2, 1)) Then
Names(c) = Names(c - 1)
Hours(c) = Cells(i + 2, 2).Value
State(c) = Cells(i + 2, 4)
c = c + 1
Else
Names(c) = Cells(i + 2, 1)
Hours(c) = Cells(i + 2, 2).Value
State(c) = Cells(i + 2, 4)
I know that the values in each array are correct because I printed them all out beforehand.