Try this
array formula**:
=CORREL(IF(Sheet2!A1<=account_opened!B1:B10,IF(Sheet2!D1>account_opened!B1:B10,account_opened!P1:P10)),account_opened!AV1:AV10)<sheet2!d1,account_opened!p1
10)),account_opened!av1:av10)< font=""><sheet2!d1,account_opened!p1
10)),account_opened!av1:av10)< font="">
</sheet2!d1,account_opened!p1
10)),account_opened!av1:av10)<></sheet2!d1,account_opened!p1
10)),account_opened!av1:av10)<><sheet2!d1,account_opened!p1

10)),account_opened!av1:av10)< font=""><sheet2!d1,account_opened!p1

10)),account_opened!av1:av10)< font="">Note that you can amend the upper row being referenced (10 here) to meet your requirements, though you should be careful not to make it too arbitrarily large (and certainly don't reference entire columns!), since, for each additional cell referenced, extra calculation will be required.
And that applies whether those additional cells are technically beyond the last-used cells in those ranges or not. With some functions, e.g. COUNTIF(S)/SUMIF(S), you can get away with referencing entire columns with no detriment to performance, though not with functions which operate over arrays, such as AGGREGATE, SUMPRODUCT, and any construction requiring CSE.
Regards
**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).</sheet2!d1,account_opened!p1

10)),account_opened!av1:av10)<></sheet2!d1,account_opened!p1

10)),account_opened!av1:av10)<>
<sheet2!d1,account_opened!p1
10)),account_opened!av1:av10)< font=""><sheet2!d1,account_opened!p1
10)),account_opened!av1:av10)< font=""></sheet2!d1,account_opened!p1
10)),account_opened!av1:av10)<></sheet2!d1,account_opened!p1
10)),account_opened!av1:av10)<>