title: Worksheets does not work
body: <p>I am trying to write an excel visual basic macro.</p>
  
  <p>My Problem is that this code works:</p>
  
  <pre><code>Dim x As String
  x = Worksheets("Abgabe").Cells(20, 3).Value
  </code></pre>
  
  <p>But this doesn't:</p>
  
  <pre><code>Dim y As Worksheet
  y = Worksheets("Abgabe")
  </code></pre>
  
  <p>Also if I use ActiveWorkbook the code doesn't work.</p>
  
  <pre><code>Dim y As Worksheet
  y = ActiveWorkbook.Worksheets("Abgabe")
  </code></pre>
  
  <p>I'm getting this error:</p>
  
  <blockquote>
    <p>Object variable or With block variable not set</p>
  </blockquote>
  
  <p>What could be the problem?</p>