title: How to validate a string entered in the input box against an excel range which contains that string?
body: <p>Please excuse me for this question as I'm a novice. I'm trying to enter a string in the VBA inputbox and take that string and validate against a range containing a list of strings in an excel sheet("Roles"). If the string is present in the range, then I would like to display the value in the next column using Vlookup and display that in a msg box. Otherwise I would like to have a msgbox displaying the "string doesn't exist". I have the below code which I can't get it to work. When I execute the code,I get a type mismatch error Highly appreciate your help !</p>
  
  <pre><code>Option Explicit
  
  Sub GetRoles()
      Dim Name As String
      Dim Role As String
  
      Name = InputBox("Enter a Name")
      Sheets("Roles").Activate
  
      If Range("name_list").Value = Name Then
          Role = WorksheetFunction.VLookup(Name, Range("name_list"), 2, False)
          MsgBox Name &amp; " is a " &amp; Role
      Else
          MsgBox Name &amp; " does not exist"
      End If
  End Sub
  </code></pre>