title: VBA: subroutine with if statement and returning true or false?
body: <p><em><strong>SOLVED!</em></strong></p>
  
  <p>I have to validate that certain cells are not empty, so I want to create a subroutine and pass the variables I need checked.</p>
  
  <p>This is what I came up with:</p>
  
  <pre><code>Sub errorMessage(errMsg As String, errRange As String)
  If Range(errRange) = "" Then
      MsgBox errMsg, , "Error:"
      Range(errRange).Activate
      'this is what i was looking for :doh:, the 'end' line terminates everything..
      END
  End Sub
  </code></pre>
  
  <p>Now when I call it from my button, will it actuall end the sub of the button?</p>
  
  <p>i.e.</p>
  
  <pre><code>Private Sub CommandButton1_Click()
  
      Call errorMessage("name is missing", "D4")
  
      'this function shouldn't be called if there was a msgbox displayed with the above call 
  sendEmail 
  
  
  End Sub
  </code></pre>
  
  <p>How can i make this happen? </p>
  
  <p><em><strong>EDIT:</em></strong> </p>
  
  <p>OK So this is how i sovled it, the reason i'm trying to do this is to avoid tons of lines of code in the buttonClick sub, what are your thoughts??</p>
  
  <p>keep in mind that this thing has to check about 25 questions for blanks before executing the sendEmail sub....</p>
  
  <pre><code>Private Sub CommandButton1_Click()
  
  
      Call validateEntry("Client Name is missing.", "D4")
      Call validateEntry("# not complete.", "D5")
  
  
      Call validateEntry("Address same as CV?", "D6")
  
  
      Call validateEntry("Number missing.", "D8")
      Call validateEntry("Type missing.", "D9")
      Call validateEntry("Q1 requires a Yes or No.", "E19")
      Call validateEntry("Q2 requires a Yes or No.", "E21")
      Call validateEntry("Q3 requires a Yes or No.", "E23")
      Call validateEntry("Q4 requires a Yes or No.", "E25")
      Call validateEntry("Q5 requires a Date.", "D28")
      Call validateEntry("Q6 requires a Yes or No.", "E30")
      Call validateEntry("Q7 requires a Yes or No.", "E32")
  
  
  
  MsgBox "passed"
  'sendEmail
  End Sub
  
  
  Sub validateEntry(errMsg As String, errRange As String)
      If Range(errRange) = "" Then
          MsgBox errMsg, , "Error:"
          Range(errRange).Activate
          End
      End If
  End Sub
  </code></pre>