I have a scientific instrument collecting data points 24/7, resulting in tens of thousands of points a day. It collects from multiple positions, 1-16, cycling through the positions on a roughly 20 minute interval (ie: from 12:00-12:20 it is at 1, then 12:20-12:40 it is at 2 ...)

The relevant inputs are then:
A2:Axxxxxx is position
B2:Bxxxxxx is data point

I need to average the data points for each cycle of each position, so have an average of column B based on it being from the same 20-ish minute cycle as determined by column A. This would have to be repeated for all the 20 minute cycles.

I have seen macros for averaging intervals, but nothing with dependent, variable ranges based on separate columns. I am not even sure if an excel macro could do this. Any help would be greatly appreciated!