title: Selecting a range of cells based on a loop variable
body: <p>I've tried for days to find an answer to this but honestly, it might be a lack of knowledge in the subject that's causing me to not search for the right terms.</p>
  
  <p>I have a spreadsheet with a series of dates between S7:GE7 and rows from 8:96 that have data that need to be locked the next day.</p>
  
  <p>I know my way of selecting the columns is all wrong, and there's probably more wrong too but I can't think of a way to make it right.</p>
  
  <pre><code>Private Sub Workbook_Open()
  
  Dim i As Range, cell As Range
  Set i = Range("S7:GE7")
  
  For Each cell In i
        If (cell.Value &lt; DateValue(Now())) Then
            Range(i + "8:96").Locked = True
        End If
  Next cell
  
  End Sub
  </code></pre>
  
  <p>What I'm hoping to achieve with this is a loop that looks through the dates in S7:GE7, and if the date is older than today it locks cells 8:96 in that column.</p>
  
  <p>Any help that can be provided would be much appreciated. Thanks</p>