You can use dynamic named ranges and refer them in your array formulas. You can define dynamic named ranges by using the following formula.

=OFFSET(Sheet1!$A$2,0,0,COUNTA(Sheet2!$A:$A)-1,1)

In this case you are creating a dynamic named range in column A where A1 contains the header and the values start from A2.