title: How to set focus back to textbox after an error message.?
body: <p>I have a user form with several textboxes and need to validate data upon clicking the last command button on the form. The code is:</p>
  
  <pre><code>Private Sub CmdSave1_Click()
  
   Dim row As Long
    Dim c As Range
   row = ActiveCell.row
  
  
    For Each c In Range("A2:A" &amp; Cells(Rows.Count, 1).End(xlUp).row)
       If c.Value = txt_BPName1 Then
          MsgBox " Duplicate Found.Please enter unique Base Product"
          txt_BPName1.SetFocus  '&gt;&gt;&gt; the cursor does not return textbox here.
                'txt_SPName1.SetFocus
                  End If
                  Next
                  'txt_SPName1.SetFocus
                  'Exit Sub
       For Each c In Range("B2:B" &amp; Cells(Rows.Count, 1).End(xlUp).row)
           If c.Value = txt_SPName1 Then
             MsgBox "Cell " &amp; c.Address &amp; " Duplicate sub Product Found."
                txt_SPName1.SetFocus
                End If
                Next
                'txt_loc1.SetFocus
                'Exit Sub
  </code></pre>
  
  <p>Exit sub will put the cursor back into the textbox. But, I have other lines of code that need to happen below exit sub line. So, I do not want to exit sub. Is there a substitute for exit sub? Or can I break out and enter the sub back again?</p>