Reputation: 907
I am using a while loop and the AND condition is not working correctly
For Each y In ws.Range("C1:C" & ws.Range("A1000000").End(xlUp).Row)
If InStr(y, "Total") > 0 Then
i = -1
Do While (InStr(ws.Range("C" & y.Row).Offset(i, 0), Right(y, Len(y) - InStr(y, " "))) = 0 And InStr(ws.Range("C" & y.Row).Offset(i, 0), "%)") = 0)
i = i - 1
Loop
End If
Next y
The second instr is not working and I am getting false positives. Basically, the code finds a word starting with total, then it takes the string after the "Total " and looks for that word, but the word should also have "%)" in it
Upvotes: 0
Views: 364
Reputation:
You are not using the InStr
function properly.
Syntax
InStr( [start], string, substring, [compare] )
Upvotes: 1