This is an ideal application for Pivot Table.
No formula or code is required.
Assume your data looks like this:
Z1 Z2 Z3 Z4
Y1 27 81 20 55
Y1 39 21 93 23
Y1 75 63 86 37
Y1 82 73 61 22
Y2 43 92 86 24
Y2 67 36 67 64
Y2 44 22 32 96
Y2 31 40 38 91
Y3 91 60 37 17
Y3 19 86 31 37
Y3 35 72 84 88
Y3 76 93 58 27
Data Pivot Table Multiple Consolidation Ranges
Range: Select the above 13 x 5 array
Layout: DATA = Average of Value
Options: Uncheck Grand Totals, AutoFormat
The result will look like this:
Average of Value Column
Row Z1 Z2 Z3 Z4
Y1 55.75 59.50 65.00 34.25
Y2 46.25 47.50 55.75 68.75
Y3 55.25 77.75 52.50 42.25
Month and Year data can be added in
the Range table and shown in PAGE fields.
More at Debra Dalgleish site:
www.contextures.com