Обычно я делаю общую фильтрацию по строкам следующим образом:
criterion = lambda row: row['countries'] not in countries
not_in = df[df.apply(criterion, axis=1)]
Циклы медленны. Матч быстрый, и последняя заполненная ячейка может быть легко расположена снизу вверх.
dim aio as variant, keyCells As Range
with worksheets("sheet1")
aio = application.match("Added Info/Options", .columns(5), 0)
if not iserror(aio) then
set keyCells = .range(.cells(aio+1, "E"), .cells(.rows.count, "D").end(xlup).offset(0, 1))
else
debug.print "Added Info/Options not found"
end if
end with
Dim f As Range, KeyCells As Range
With ActiveSheet
Set f = .Rows(5).Find(What:="Added Info/Options", lookat:=xlWhole)
If Not f Is Nothing Then
Set f = f.Offset(1, -1)
Set KeyCells = .Range(f, .Cells(.Rows.Count, f.Column).End(xlUp))
Else
Msgbox "Required header not found!"
End If
End With