title: Excel VBA: Formula with reference to cell in another worksheet (variable)
body: <p>I am trying to create a macro that links a cell from another worksheet (this is stored as a variable called SheetName). The user is prompted with an Input box to select a cell. I would like to have a cell in another worksheet reference to the selected cell. </p>
  
  <p>Here is the relevant code: </p>
  
  <pre><code>Dim WorkRng As Range
      Total1 = "Select Total cell"
      Set WorkRng = Application.Selection
      Set WorkRng = Application.InputBox("Range", Total1, WorkRng.Address, Type:=8)
      Worksheets("WorksheetA").Range("C6").formula = "=" &amp; 'SheetName.Name' &amp; "!" &amp; WorkRng.Address
  </code></pre>
  
  <p>The last line is where I am running into object errors.
  Any help is greatly appreciated!</p>