title: VBA Excel Instr() StrComp() not working properly
body: <p>I am trying to compare two strings, however, the functions are returning bad matches. I tired using three different methods and posting the results for each method in different columns to test. I tired to compare using "string1" = "string2", instr(), and strcomp(). </p>
  
  <p>they dont even return the same results for each method when using the same two strings; sometimes one type of comparison is true and others may not be. </p>
  
  <p>for false positives, Instr() returns a position, but substring is not in target string, Strcomp() returns 0 but the words are not the same, and "string1" = string2" is true but the strings are different.</p>
  
  <pre><code>Worksheets("hemo").Cells(f, 1) = Trim(Worksheets(Stabv).Cells(Count, 1))
  Worksheets("hemo").Cells(f, 2) = Len(Trim(Worksheets(Stabv).Cells(Count, 1)))
  Worksheets("hemo").Cells(f, 3) = Trim(LitBaseArray(y))
  Worksheets("hemo").Cells(f, 4) = Len(Trim(LitBaseArray(y)))
  
  scrapeString1 = Trim(Worksheets(Stabv).Cells(Count, 1))
  scrapeString2 = Trim(LitBaseArray(y))
  
  If scrapeString1 = scrapeString2 Then
  Worksheets("hemo").Cells(f, 5) = "true"
  End If
  
  If StrComp(Trim(scrapeString1), Trim(scrapeString2), vbTextCompare) = 0 Then
  Worksheets("hemo").Cells(f, 6) = "true    " &amp; StrComp(Trim(scrapeString1), Trim(scrapeString2), vbTextCompare)
  End If
  
  If InStr(1, Trim(scrapeString1), Trim(scrapeString2), vbTextCompare) &gt; 0 Then
  Worksheets("hemo").Cells(f, 7) = "true    " &amp; InStr(1, Trim(scrapeString1), Trim(scrapeString2), vbTextCompare)
  End If
  
  f = f + 1
  </code></pre>