title: VBA Vlookup always returns #N/A
body: <p>I have two separate workbooks with data. I'm trying to find cell value matches using vlookup.</p>
  
  <p>The column in Workbook one contains alphanumeric data as does the column being compared to in Workbook 2. </p>
  
  <p>I have the following code to try and determine matches:</p>
  
  <pre><code>    Sub VirtualHostLookUp()
  
      'TO DO: iterate through all required workbooks and do lookup
  
      'open the workbook of interest
      'Workbooks.Open ("C:\Documents and Settings\1147808\My Documents\Pete\Data\tester.xlsx")
  
      'define this workbook
      Dim campus As Workbook
      Set campus = Workbooks(1)
  
      'define the lookup range - currently opens the first second open workbook
      Dim rng As range
      If Workbooks.Count &gt; 1 Then
          With Workbooks(2)
              Set rng = .Worksheets(2).UsedRange
          End With
      End If
  
      'initialise starting point
      Dim currRow, currCol As Integer
      currRow = 3
      currCol = 19
  
      'get first value to compare
      Dim currVal As Variant
      currVal = Cells(currRow, currCol).Value
  
      'find the number of rows in the column
      Dim totalRows As Long
      With campus.Worksheets(1)
          totalRows = .Cells(.Rows.Count, "S").End(xlUp).Row
      End With
  
      campus.Activate
  
      'iterate through the rows
      For i = currRow To totalRows
  
          Dim cell As Variant
          Set cell = campus.Worksheets(1).Cells(currRow, currCol + 2)
  
          If currVal &lt;&gt; Empty Then
              cell.Value = Application.VLookup(currVal, rng, 2, False)
  
              If Not IsError(cell.Value) Then
                  If cell.Value = Empty Then
                      cell.Value = "MATCH"
                  End If
              End If
          End If
  
          'cell.Value = ""
  
          currRow = currRow + 1
          currVal = Cells(currRow, currCol).Value
      Next 
  End Sub
  </code></pre>
  
  <p>I know there are matches between the two columns but the value "#N/A" is always returned and I cannot figure out why?</p>
  
  <p>I have define the range as the UsedRange in Workbook2, this works and returns the correct values. The data to match against is in column 2 of Workbook 2. </p>
  
  <p>What am I doing wrong?!?!</p>