I am trying to do a simple loop, where I have declared some variables as array entries. I originally used them as variables to be overwritten, but changed it when I read that these variables will not automatically overwrite each time through the loop.
My problem is that this loop terminates after the first iteration (with no error). I can't seem to figure out why...
The code is essentially to find cons_sum(i,2) for each i, or row in the Pre-Summary sheet and sum some data in another sheet BOPE, then insert that sum into Pre-Summary.
This is my first post and I am teaching myself vba so please excuse any code fails.
This is my code:
Option Explicit
Sub Create_GAR080()
    Consmonth = Sheets("GAR080").Range("B2").Value
    Sheets("Pre-Summary").Select
    LastRow_summary = Cells(Rows.Count, "A").End(xlUp).Row
    LastRow = 156
    LastCol = 16
    Dim cons_sum() As Variant
    ReDim cons_sum(LastRow_summary, 4)
    For i = 1 To LastRow_summary Step 1
        cons_sum(i, 1) = Cells(i, 2).Value & "" 'pulls participant
        cons_sum(i, 2) = cons_sum(i, 1) & Cells(i, 1) ' participant and gas gate concatenated
        If cons_sum(i, 1) = "BOPE" Then
             Sheets(cons_sum(i, 1)).Select
             cons_sum(i, 3) = WorksheetFunction.Match(cons_sum(i, 2), Sheets(cons_sum(i, 1)).Range("A:A")) ' find participant gas gate combo
             cons_sum(i, 4) = Application.Sum(Sheets(cons_sum(i, 1)).Range(Cells(cons_sum(i, 3), 5), Cells(cons_sum(i, 3), 16)))
             If cons_sum(i, 4) > 0 Then
                Sheets("Pre-Summary").Cells(i, 4).Value = cons_sum(i, 4)
             End If
        End If
    Next i
    On Error Resume Next
End Sub
 
     
     
    