title: Excel VBA VLookup on a tables second column
body: <p>Just trying to see if its possible to use VLookup on the second column of a table? I have searched endlessly and cant find an answer to this but I feel like this should be possible.</p>
  
  <p>I'll add at this point that VBA is not my strong point. I come from a PHP/MySQL background but dont have the luxury of using either at my work so Im resorting to learning VBA.</p>
  
  <p>My code so far (simplified):</p>
  
  <pre><code>Dim userEnviron As String
  Dim rowId As Integer
  
  rowId = 0
  userEnviron = Environ("Username")
  
  Dim tbladmin As ListObject
  Set tbladmin = Sheets("Office Details").ListObjects("officeAdmin")
  
  On Error Resume Next
  rowId = Application.VLookup(userEnviron , Range(tbladmin), 4, False)
  </code></pre>
  
  <p>This code is looking up the user environmental variable and looking for a match in the tbldadmin table. The table is constructed like so with headers:</p>
  
  <p><code>Name                 UserID             Email                 RowID
  Tom Smith             Tom                the@the.com           2</code></p>
  
  <p>Im trying to lookup the UserID and return the Name, however at the moment I have the code set to lookup the Name and return the RowID (I had added a second snippet of code to take the RowID and return the name)</p>
  
  <p>I can see a lot of non-VBA examples where this is done, however none that appear to use tables.</p>
  
  <p>Can VLookup be used as described, to search for a match in the second column and return a value from the first column? Hell I'll take a return from the last column if only I can search the second column.</p>