title: Using VBA If then statement to copy and paste data
body: <p>I am a brand new VBA user attempting to copy and paste data based on a range of dates. In column one I have dates and in column two I have the data I would like to copy and paste. CurYear refers to the end date in the range I am looking for and StatDate refers to the beginning date in the Range I am looking for. When I run this code it crashes Excel. Please help I am very lost </p>
  
  <pre><code>Worksheets("Weekly").Select
  
  Dim nRows As Integer
  Dim CurYear As Date
  Dim StartDate As Date
  
  nRows=Range("A1").CurrentRegions.Count.Rows
  CurYear=Range("I265").Value
  StartDate=Range("M5").Value
  
  Do While Cells(nRows,1)&lt;&gt;""
  
  if Cells(nRows,1).Value&lt; CurYear &amp; Cells(nRows,1)&gt; StartDate Then
  
  Cells(nRows,1).Offset(0,1).Copy
  Worksheets("Weekly").Range("H41").Paste
  
  Loop
  End If
  </code></pre>