My Excel formulas used to break all the time until I found this function: AGGREGATE

My Excel formulas used to break all the time until I found this function
www.makeuseof.com/excel-formulas-used-to-break-until-i-found-this-function/

AGGREGATE does what other functions can’t. Here’s how the syntax works
It also handles hidden and filtered rows correctly. Your calculations stay accurate even when rows are out of sight
AGGREGATE can replace 19 different functions. And a few of them are very useful
Everyday scenarios where AGGREGATE pays off
AGGREGATE pairs well with other Excel functions. Try combining it with conditional logic for even more control

AGGREGATE function – Microsoft Support
support.microsoft.com/en-us/office/aggregate-function-43b9278e-6aa7-4f17-92b6-e19993fa26df