title: VBA Detecting an error and stopping the code
body: <p>I currently have this, but I dont necessarily need a loop. I just need to see if there is any error in the usedrange, and if yes, stop the code and display the message. If no error, then just continue with the rest of the steps that are after this part of the code. Right now this loop displays this message for every error detected. I just need it to be displayed once if any error is found, and then stop the code. </p>
  
  <pre><code>Dim r As Range
  
  For Each r In ws_DST.UsedRange
      If IsError(r.Value) Then
          MsgBox "Please fix any errors", vbOKOnly
      End If
  Next
  End 
  </code></pre>