Let's say your criteria cells start in A1, and col A will contain the max amount of rows. Dynamic range (MyCriteria) would be defined as:
=OFFSET($A$1,0,0,COUNTA($A:$A),COUNTA($1:$1))
Then, in the Advanced Filter, where it asks for the range, you simply type:
MyCriteria