title: Loop through cells and display a message if a value is not found
body: <p>I have a macro that loops through cells of one sheet, looks for that value in another sheet, and then highlights the row if they match. I'd like to add a message box that would pop up if a matching value is not found. I know this is a simple problem, but I'm having trouble figuring out in which loop to put my booleans.</p>
  
  <pre><code>
  Sub MarkXfer_noX()
  
  Dim rng As Range
  Dim rng2 As Range
  Set rng = Worksheets("Transferred Routings").UsedRange
  Dim i As Integer
  Dim j As Integer
  Dim ProdCI As String
  Dim found As Boolean
  Dim intRowCount As Integer
  
  
  intRowCount = Sheets("Transferred Routings").UsedRange.Rows.count
  
  For i = 2 To intRowCount
  
          If rng.Cells(i, 1) &lt;&gt; "" Then ProdCI = rng.Cells(i, 1) 'get the ProdCI number from column A if not blank
          Worksheets("All_ProCI").Activate 'activate main page
          Set rng2 = Worksheets("All_ProCI").UsedRange 'select a range on the main page
  
              For j = 2 To rng2.Rows.count 'from row 2 to the end
                  If rng2.Cells(j, 2) = ProdCI Then 'if the ProdCI in column B matches the one we picked,
                      Call FillCell(j) 'call a sub in a different module and give it our current row
                      found = True
                  Else
                      found = False
                  End If
              Next
  
     Next
  
     If found = False Then
     MsgBox (ProdCI &amp; " not found") 'Display a message if one of the items wasn't found on the main page. Currently has an error where the last one in the list always pops up.
     Else
     End If
  
  End Sub
  </code></pre>
  
  <p>Right now it always shows a msgbox with the last value in the range no matter what.</p>