Hello all, I am pretty new to constructing more complex excel functions, so I will try my best to explain what my goals are.

=AVERAGEIFS(E2:E721,E2:E721,"<"&(AVERAGEIF(E2:E721,"<>0"))+(2*(STDEV(E2:E721))),E2:E721,">"&(AVERAGEIF(E2:E721, "<>0"))-(2*(STDEV(E2:E721))))
This formula was used to to provide an average of all data that fell within +/- 2 standard deviations (used as a general outlier eliminator) that was not a 0. Now I would like to determine the average of a smaller subset (E622:E721) of the data, but still exclude any values (in the smaller subset) that are outside 2 standard deviations of the larger set. How would I manipulate this formula to make this possible (I've tried and keep getting #value errors)? The goal is to get this all done in one all-inclusive formula and my brain is fried from looking at data all day and as a result I'm having a hard time using common sense anymore . Any help would be greatly appreciated.