My goal is to average a number of columns in one row.
The table is laId out by month, ONE week per column and a number of rows with the numbers in each column.
The table is divided into months across the top, with the month name header in a merged cell of four or five columns depending on how many weeks the month spans (Saturdays and Sundays are omitted at the start and end of the month leading to the four or five weeks per month).
For example, November this year (2015) includes five work weeks. The range of the header is O11:S11 - a merged cell.
Above this table that spans the year, there is a cell to average the number of hours spend on project time versus overhead.
In my example for November, I would average O43:S43. I would like to type or select the month to average in one cell, then find the column range of that month from the merged cells holding November
.
For example, if the key cell is D9, holding November, and I want to place the average value in E9, and the row of months for the year spans from K11 - W11, what are the possible approaches to solving this question?
I tried using an INDEX MATCH formula but that gets me nowhere. I need to write a VBA function (I think).
Debug.Print Sheet1.Range("A1").MergeCells
- will return TRUE/FALSE and find the range of merge cells withDebug.Print Sheet1.Range("A1").MergeArea.Address
– Darren Bartrup-Cook