title: Accounting for Missing Values Loop
body: <p>I have been working on this program that...</p>
  <ol>
  <li>Finds a five-digit code in a workbook</li>
  <li>Looks in a second workbook to find a matching code</li>
  <li>Copies a set of corresponding data from the first workbook onto the second.</li>
  </ol>
  <p>It works for the most part, but when there is a value that is present on the first book but not the second it fails.  If I let it run the values get messed up, but the program does complete.  I need to find a way to recognize an error, which would be foundItem = 0, and then restart the loop from that point so nothing gets copied.  I appreciate the help.</p>
  <pre><code>Sub findExample()
  On Error Resume Next
  Dim foundItem As Range
  Dim codeValue As String
  Dim strAddress As String
  Dim endOfWorksheet As Boolean
  Dim x As Long
  
  x = 1
  Do While endOfWorksheet = False
  x = x + 1
  Sheets(&quot;Medex Center Master List&quot;).Select
  Dim NRange As String
  NRange = &quot;N&quot; + CStr(x)
  codeValue = Range(NRange, NRange).Value
  Sheets(&quot;6035P_ATRSDeviceListII&quot;).Select
  Set foundItem = Range(&quot;M1:M300&quot;).Find(codeValue)
  
  Dim col
  Dim rowa
  
  col = Split(foundItem.Address, &quot;$&quot;)(1)
  rowa = Split(foundItem.Address, &quot;$&quot;)(2)
  strAdress = col + rowa
  
  Dim FRange As String
  FRange = &quot;A&quot; + CStr(x) + &quot;:&quot; + &quot;M&quot; + CStr(x)
  Sheets(&quot;Medex Center Master List&quot;).Range(FRange).Copy Sheets(&quot;6035P_ATRSDeviceListII&quot;).Range(strAdress).Offset(0, 1)
  
  If x = 265 Then
  endOfWorksheet = True
  End If
  
  Loop
  MsgBox &quot;program completed&quot;
  End Sub
  </code></pre>
  <p>Thanks Again,
  Samuel</p>