vendredi 13 juillet 2018

Range Won't Define

Can someone help me understand why the last line doesn't run?

What I'm trying to accomplish:

Define a range that that starts with the line under the cell that contains "Added Info/Options" and ends with the last cell that contains a value in the previous column. The cell that contains "Added Info/Options" is variable.

Sample Cells to Understand Range to be Defined

So the Range would be rows i+1 to i+etc in column 5 in above picture

Thanks <3

Dim KeyCells As Range
Dim i, j, iRow, a, b As Integer
    For i = 1 To 500 Step 1
    If Not Cells(i, 5).Value = "Added Info/Options" Then
        Exit Sub
    Else:
        a = i + 1
        For iRow = a To i + 20 Step 1
            If Len(Cells(iRow, 4)) > 0 Then
                j = i + iRow
            End If
        Next iRow
    End If
    Next i
    KeyCells = Range(Cells(a, 6), Cells(j, 6))

Aucun commentaire:

Enregistrer un commentaire