title: excel vba - syntax error
body: <p>I can't quite figure out what the syntax error in Excel VBA is, the error I am seeing is: "run-time error 1004: Application-defined or object-defined error"</p>
  
  <pre><code>Sheets("Totals").Select
  x = Range("A139").Activate
  Range("E139:AB166").Formula = "=INDEX(""Model""!$A$3:$Z$1000,MATCH($" &amp; x &amp; ",""Model""!$A$3:$A$1000,0),MATCH(E$3,""Model""!$A$3:$Z$3,0))"
  </code></pre>
  
  <p>I am attempting to use an Index Match Match formula where the index reference is another worksheet in the file. I am trying to populate the formula in Range E139:AB166, such that the x variable is locked to Column A and the last match function is locked on the third row (E$3).</p>
  
  <pre><code>x = Range("A139").Activate
  </code></pre>
  
  <p>This line of code should force the cursor to that cell in the 'model' worksheet. 'Model' is the name of the worksheet in the file. I thought "" were necessary to alert vba that the string refers to the worksheet name.
  What if the worksheet name is comprised of two strings so "Model 1". What would be then the syntax, this?</p>
  
  <pre><code>""Model 1""!A3
  </code></pre>
  
  <p>'x' is the cell where new data is added, I wrote a line of code to have it dynamically changed. </p>
  
  <pre><code>x = Range("A" &amp; insert_at).Activate
  </code></pre>
  
  <p>Where insert_at is a variable that equals the last row,in the worksheet that is not empty, + 1.</p>
  
  <pre><code>insert_at = lastRow + 1
  </code></pre>
  
  <p>So the idea is to dynamically add additional data from the 'Model' worksheet to the current worksheet 'Totals' below any existing data in the 'Totals worksheet.</p>
  
  <p>I appreciate any assistance with this.</p>
  
  <p>Thanks!</p>