title: compare 2 sheet value and return match and no match value vba
body: <p>i had tried this code and return "match" value is work find.
   but have a problem such as return "no match" value wrongly.
  i think is else part problem did any way to modify this??
  thanks!!</p>
  
  <pre><code>Sub compareAndCopy()
  
      Dim lastRowE As Long
      Dim lastRowF As Long
      Dim lastRowM As Long
      Dim lastRowN As Long
  
      Dim foundTrue As Boolean
  
      ' stop screen from updating to speed things up
      Application.ScreenUpdating = False
  
      lastRowE = Sheets("Sheet2").Cells(Sheets("Sheet2").Rows.Count, "A").End(xlUp).Row
      lastRowF = Sheets("Sheet1").Cells(Sheets("Sheet1").Rows.Count, "A").End(xlUp).Row
      lastRowM = Sheets("Sheet3").Cells(Sheets("Sheet3").Rows.Count, "B").End(xlUp).Row
      lastRowN = Sheets("Sheet4").Cells(Sheets("Sheet4").Rows.Count, "B").End(xlUp).Row
  
      For i = 1 To lastRowE
          foundTrue = False
          For j = 1 To lastRowF
  
              If Sheets("Sheet2").Cells(i, 1).Value = Sheets("Sheet1").Cells(j, 1).Value Then
                  lastRowM = lastRowM + 1
                  Sheets("Sheet2").Rows(i).Copy Destination:= _
                             Sheets("Sheet3").Rows(lastRowM)
                  foundTrue = True
                  Exit For
      **else
          lastRowN = lastRowN + 1
                  Sheets("Sheet2").Rows(i).Copy Destination:= _
                             Sheets("Sheet4").Rows(lastRowN)
                  foundTrue = True
              End If**
          Next j
      Next i
  
  
      Application.ScreenUpdating = True
  End Sub
  </code></pre>