Hello prometheus,
This should work. It assumes the cells in the Do loops are on the ActiveSheet.
Dim rngData As Range
Dim rngLookup As Range
Dim Wks As Worksheet
Set Wks = Worksheets("Data")
Set rngData = Wks.Range("A1").CurrentRegion
Set rngLookup = Intersect(rngData, rngData.Columns("AI"))
If rngLookup Is Nothing Then Exit Sub
If IsError(Application.Match(Cells(21 + i, 31), rngLookup, 0)) Then
Do While Cells(21 + i, 31).Value <> ""
Cells(21 + i, 37).Value = Application.VLookup(Cells(21 + i, 31), rngData, 11, False)
i = i + 1
Loop
Else
Do While Cells(21 + i, 31).Value <> ""
Cells(21 + i, 37).Value = Application.VLookup(Cells(21 + i, 31), rngData, 12, False)
i = i + 1
Loop
End If