title: VBA Runtime Error 9: Subscript out of range
body: <p>I have been trying to write a small piece of code to validate to confirm whether or not a date is included in an array. I have been able to scroll through the code until I reach the line <code>If lists(i) = TodaysDate Then</code> when the <code>lists(i)</code> show <code>subscript out of range</code>. I have searched through the Internet and I'm unable to resolve this issue.</p>
  
  <p>My Macro reads as follows:</p>
  
  <pre><code>Sub size_an_array()
      Dim i As Integer
      Dim Range_of_Dates As Integer
      Dim TodaysDate As Variant, finish As String
      TodaysDate = Range("Sheet11!c2")
      ThisWorkbook.Worksheets("Sheet11").Activate
      lists = Range("Processed_Dates")
  
      Range_of_Dates = UBound(lists, 1) - LBound(lists, 1) + 1
  
       For c = 1 To UBound(lists, 1) ' First array dimension is rows.
           For R = 1 To UBound(lists, 2) ' Second array dimension is columns.
               Debug.Print lists(c, R)
           Next R
       Next c
  
       x = Range_of_Dates  'UBound(lists, 1)
       ReDim lists(x, 1)
  
       i = 1
       Do Until i = x
           If lists(i) = TodaysDate Then
               Exit Do
           End If
       Loop
  
       MsgBox "The date has not been found"
  
  End Sub
  </code></pre>
  
  <p>I'm relatively new to <code>VBA</code> and I have been trying to use named ranges to pull in the array but I'm completely at my wits end in trying to solve this piece.</p>
  
  <p>Any help would be greatly appreciated.</p>