title: VBA application.match error 2015
body: <p>In my <code>Main</code> procedure I want to write a quick if-statement which checks whether the user has made a valid input (user chooses number of project from list of data, see attached screenshot). For that I am checking whether the project number is not part of the list of projects. If that is true, an error message is displayed; if not then a number of other procedures are called.</p>
  
  <p>For some reason though I get error 2015 when I run it, which means that the if-statement is always true, even on correct user entries. Can someone help me understand the error please?</p>
  
  <ul>
  <li>The project number input is a named cell called "IdSelect" and is on a sheet called "Invoice"</li>
  <li>The data against which this input is checked is on a sheet called "Input"</li>
  <li>The data is stored in column B and called "ProjectList"</li>
  </ul>
  
  <p>Code below (note: I have tried pasting it 5 times but the formatting still won't work this time for some reason - any idea what that could be? The code is properly formatted. Sorry for the messy display; if anyone can tell me what that problem might I would be very grateful!)</p>
  
  <pre><code>Sub Main()
      'Turn off screen updating
      Application.ScreenUpdating = False
      'Define variable for currently active cell to reactivate it afterwards
      Dim OldActiveSheet As Object
      Dim OldActiveCell As Object
      Dim i As Integer
      Dim ProjectList As Range
      Set OldActiveSheet = ActiveSheet
      Set OldActiveCell = ActiveCell
      'If-statement to check whether project number is valid or not
      Worksheets("Invoice").Activate
      'Print to Immediate Window to check value - remove later
      Debug.Print Range("IdSelect").Value
      If IsError(Application.Match(Range("IdSelect").Value, "ProjectList", 0)) Then
          'Print to Immediate Window to check value - remove later
          Debug.Print Application.Match(Range("IdSelect").Value, Worksheets("Input").Range("ProjectList"), 0)
          MsgBox "Invalid Choice: Project with this number does not exist!"
          Exit Sub
      Else
          'Call procedures to execute
          Call SortData
          Call Count_Line_Items
          Call Count_Total_Rows
          Call Write_Services(ServCnt)
          Call Write_Expenses(ExpCnt)
      End If
      'Reactivate previous active cell
      OldActiveSheet.Activate
      OldActiveCell.Activate
  End Sub
  </code></pre>
  
  <p>Screenshot from "Input" sheet:</p>
  
  <p><img src="https://i.stack.imgur.com/G4m2G.png" alt="enter image description here"></p>