title: VBA Formula: Variable File Name and Variable Sheet Name
body: <p>I am trying to create a cell reference to a cell in another workbook.  In my code below, I am using a variable for workbook name and sheet name.</p>
  
  <ul>
  <li><code>SourceFileNamePath</code> = Path and name of workbook I am linking to</li>
  <li><code>SourceTab</code> = Tab in the workbook I want to link to</li>
  </ul>
  
  <p>Though the code runs fine, the formula generated is not working.  Does anyone have any thoughts on whether I am referencing <code>SourceFileNamePath</code> and <code>SourceTab</code> correctly?</p>
  
  <p>Code is below:</p>
  
  <pre><code>Cells(destStartRow, destStartCol).FormulaR1C1 = "='[" &amp; SourceFileNamePath &amp; "]" &amp; SourceTab &amp; "'!R" &amp; sourceStartRow &amp; "C" &amp; sourceStartCol
  </code></pre>