title: How to reference cells in range?
body: <p>Based on the text (&quot;SNV&quot;) present in column L of the &quot;HiddenSheet&quot; worksheet, I would like to select and copy cells in columns 1 to 6 for all rows for which the &quot;SNV&quot; text is present in column L.</p>
  <p>Then I would like to paste the values of the copied cells in the SNVReports worksheet.</p>
  <pre class="lang-vb prettyprint-override"><code>Sub Macro2()
  
  a = Worksheets(&quot;HiddenSheet&quot;).Cells(Rows.Count, 1).End(xlUp).Row
  
  For i = 1 To a
  
      If Worksheets(&quot;HiddenSheet&quot;).Cells(i, 12).Value = &quot;SNV&quot; Then
  
          Worksheets(&quot;HiddenSheet&quot;).Range(Cells(i, 1), Cells(i, 6)).Copy
          Worksheets(&quot;SNVReports&quot;).Activate
          b = Worksheets(&quot;SNVReports&quot;).Cells(Rows.Count, 1).End(xlUp).Row
          Worksheets(&quot;SNVReports&quot;).Cells(b + 1, 1).Select
          ActiveSheet.Paste
          Worksheets(&quot;HiddenSheet&quot;).Activate
  
      End If
  Next
  
  Application.CutCopyMode = False
  
  End Sub
  </code></pre>
  <p>I sometimes receive:</p>
  <blockquote>
  <p>&quot;Application-defined or object-defined error&quot;</p>
  </blockquote>
  <p>and it is apparently related to my range:</p>
  <pre class="lang-vb prettyprint-override"><code>Worksheets(&quot;HiddenSheet&quot;).Range(Cells(i, 1), Cells(i, 6)).Copy
  </code></pre>