I was recently helping someone with a budget which they had built vertically, with the months going down the sheet. They then asked to display it horizontally, with the months going across the page. In the latest version of Excel this is straightforward.
The image below shows the structure we are starting with. You can download the example file at the button at the bottom of the post.
The yellow cells are for input. The formulas in cells A6 to E6 populate the cells beneath as they are dynamic array formulas. They will all expand based on the single entry in cell B1.
We want the highlighted cells in the image to be displayed across the sheet.
The issue is that range may expand if the value in cell B1 increases– see image below.
To handle that possible expansion, we can use the OFFSET function.
The formula in cell G1 that provides a flexible solution is.
The range to be transposed starts in cell B4. The end cell is provided by the OFFSET function as it on the other side of the colon in the range reference.
Based on the first image above, the OFFSET starts in cell A4. The second argument is B1+1. This value moves rows down from A4. In this case 12+1=13 rows down from A4 to A17. The 4 on the end moves 4 columns across from A17 to the right to cell E17 in this case.
The TRANSPOSE function uses the range B4:E17 to create the transposed range.
The TRANSPOSE function is in cell G1. It spills across and down as far as required to fit the range. Spilling is a term used in dynamic arrays.
This allows the calculations to be in one layout (vertical) but it can be displayed in another layout (horizontal).
You can learn more about dynamic arrays from this earlier blog post.