title: pass sheet to a function (excel vba)
body: <p>I've been trying to pass a sheet in my workbook to a function, but it doesn't seem to be working. The function is</p>
  
  <pre><code>Private Sub passToSheet(theData As Variant, Optional mySheet As Worksheet)
  </code></pre>
  
  <p>I have tried doing</p>
  
  <pre><code>Dim mySheet as Worksheet
  Set mySheet = "Results"
  </code></pre>
  
  <p>then to call the function</p>
  
  <pre><code>passToSheet theData mySheet
  </code></pre>
  
  <p>but it doesn't seem to work. I'm not really sure what to google to get the right way to reference the worksheet though! Any help is much appreciated!</p>