title: Cannot create table VBA excel
body: <p>When I run this function        </p>
  
  <pre><code>    Call makeTable("Uber Tracker", range(Cells(7, 1), Cells(LastUber, 42)))
      Call makeTable("Finance Tracker", range(Cells(21, 1), Cells(LastFinance, 23)))
  </code></pre>
  
  <p>The first call works fine, but the second shows error 1004 worksheet range must be on the same sheet as the table being created.</p>
  
  <pre><code>    Sub makeTable(TableSheet As String, TableRange As range)
          On Error GoTo errorHandler
          Sheets(TableSheet).ListObjects.Add(xlSrcRange, TableRange, ,xlYes).name = TableSheet
  
      errorHandler:
          If Err.Number &lt;&gt; 0 Then
              Debug.Print "Error number :" + CStr(Err.Number) + " reason: " + Err.Description
          End If
  
      End Sub
  </code></pre>
  
  <p>What is wrong? I have checked which sheet it is selecting, and it should be correct, same for the range.</p>