Hello,

I am working a program that is supposed to take a value the user inputs, search a database for it, and within all the entries that have that value, find another user input quality. I'm having trouble with my second loop. The code is below:
Sub FindRowToInsert()
    Dim EngyrEnter As String, DbEngyr As String
    Dim Location As Integer, i As Integer, Row As Integer
    Dim Yes As Boolean
    Yes = False

    

    'loop goes through all occupied rows
    For i = 1 To [A65536].End(xlUp).Row
        
        'If the cell value is the specified power family,
        If Trim(Cells(i, 1).Value) = InputForm.cboPwrFam.Value Then
            Dim StartIndex As Range
            Set StartIndex = Cells(i, 1)
            

            Dim EngSizeEnter As String
            EngSizeEnter = Mid(InputForm.txtEngFam.Value, 6, 4)
            'loop looks through all rows within specified power family
            For Row = i To (i + (NumInFam - 1))
                
                Dim DbEngSize As String
                DbEngSize = Mid(Cells(Row, 2).Value, 6, 4)
               
                'If the new engine size is smaller than the cells engine size, inserts engine
                If EngSizeEnter < DbEngSize And Mid(Cells(i + Row, 2).Text, 10, 3) = Mid(InputForm.txtEngFam.Text, 6, 4) Then
                        Cells(1, i + Row).Select
                        PutInEngine
                        Yes = True
                End If
                'If new engine size is equal to cells engine size and type is the same,
                If EngSizeEnter = DbEngSize And Mid(Cells(i + Row, 2).Text, 10, 3) = Mid(InputForm.txtEngFam.Text, 6, 4) Then
                    EngyrEnter = Mid(InputForm.txtEngFam.Text, 1, 1)
                    DbEngyr = Mid(Cells(i + Row, 2).Value, 1, 1)
                    'and the year is equal
                    If EngyrEnter = DbEngyr Then
                        'Inserts engine
                        Cells(i + Row, 2).Select
                        PutInEngine
                        Yes = True
                    Else
                        Yes = False
                    End If
                End If
                'If new engine size is greater than cells engine then goes to next row
                If EngSizeEnter > DbEngSize Then
                    Row = Row + 1
                End If
            Next Row
            'If loop has completed and engine has not been inserted, inserts at last row of power family
            If Yes = False Then
                Cells(i + NumInFam, 1).Select
                PutInEngine
            End If
        End If
    Next i
End Sub
I'm not getting any compile or runtime errors, but while stepping through the program, I found that the program will correctly execute this line:
            EngSizeEnter = Mid(InputForm.txtEngFam.Value, 6, 4)
which is inside the first loop and outside of the second loop, but not this line of code:
DbEngSize = Mid(Cells(Row, 2).Value, 6, 4)
and will therefore not perform any of the if statements after this line. After it executes the "For Row =" line, it goes directly to "if yes = false"

Any ideas why this could be happening?