title: Use Me. in functions
body: <p>First my sub looked like this:</p>
  
  <pre><code>Sub DeleteGraph()
  
  For Each objCht In Me.ChartObjects
      For Each s In objCht.Chart.SeriesCollection
          s.Delete
      Next s
  Next objCht
  
  End Sub
  </code></pre>
  
  <p>This didn't work when called from the main code because of Me.</p>
  
  <p>Then I tried this:</p>
  
  <pre><code>Sub Main()
  
       Dim test As Worksheet
       Set test = Me.CodeName
       DeleteGraph test
  End sub
  
  Sub DeleteGraph(sheets As Worksheet)
      For Each objCht In sheets.ChartObjects
          For Each s In objCht.Chart.SeriesCollection
              s.Delete
          Next s
      Next objCht
  End Sub
  </code></pre>
  
  <p>This didn't work of the "Set test = Me.CodeName"</p>
  
  <p>I searched around the web and found out that I might have to use 'CallByName' but I can't seem to make it work. Is this the right approach and if so, how?</p>
  
  <p>Thank you!</p>