title: Login form with username and password from worksheet list
body: <p>I am trying to do a login form validating the password and username from sheet &quot;users&quot;. It works when the username and password are correct.</p>
  <p>When username or password are not correct (not a match to list on sheet &quot;users&quot;) I want label8 to print &quot;insert username and Password&quot; and not give access to userform1.</p>
  <pre class="lang-vb prettyprint-override"><code>Private Sub LoginBTT_Click()
  
  Application.Visible = False
  
  Dim temp As String
  
  Pw = WorksheetFunction.VLookup(Me.TextBox1.Value, Worksheets(&quot;users&quot;).Range(&quot;a2:b6&quot;), 2, 0)
  
  If TextBox2.Value = Pw Then
      Me.Hide: Application.Visible = False
      Unload Me
      UserForm1.Show
  Else
      TextBox1.Value = &quot;&quot;
      Label5.Visible = True
      TextBox2.Value = &quot;&quot;
      Label7.Visible = True
      Me.TextBox1.SetFocus
      Label8 = &quot;Wrong Username or Password&quot;
  End If
  
  End Sub
  </code></pre>