Expanding Models Automatically
Swipe to show menu
Excel Tables automatically expand structured references, but some calculations still rely on standard ranges. In this chapter, build dynamic ranges that automatically grow together with the dataset.
COUNTA Structure
=COUNTA(value1, [value2], ...)
value1: first range or value being counted;[value2]: optional additional ranges or values.
COUNTA counts all non-empty cells.
Formula used in this chapter:
=COUNTA(Sales_Data[Revenue])
This returns the current number of populated Revenue rows.
OFFSET Structure
=OFFSET(reference, rows, cols, [height], [width])
reference: starting cell;rows: vertical movement;cols: horizontal movement;[height]: returned range height;[width]: returned range width.
OFFSET builds a range dynamically relative to a starting position.
Dynamic OFFSET Formula
=SUM(OFFSET(Sales_Data!$H$1,1,0,COUNTA(Sales_Data!$H:$H)-1,1))
Sales_Data!$H$1: starting reference;1: skips the header row;COUNTA(...) - 1: dynamic dataset height;1: returned range width.
The formula automatically adjusts as new rows are added.
Inside the Summary sheet, type:
=COUNTA(Sales_Data[Revenue])
Confirm that the result matches the current number of Revenue rows.
Type:
=SUM(OFFSET(Sales_Data!$H$1,1,0,COUNTA(Sales_Data!$H:$H)-1,1))
The total Revenue calculation now expands dynamically with the dataset.
Add a new transaction row inside Sales_Data.
Confirm that the Revenue total updates automatically.
Open the Name Manager and create:
DynamicRevenue
Assign the following formula:
=OFFSET(Sales_Data!$H$1,1,0,COUNTA(Sales_Data!$H:$H)-1,1)
Replace the previous formula with:
=SUM(DynamicRevenue)
The logic remains dynamic, but the formula becomes easier to read and maintain.
Create another Named Range:
DynamicProfit
Assign:
=OFFSET(Sales_Data!$J$1,1,0,COUNTA(Sales_Data!$J:$J)-1,1)
Type:
=SUM(DynamicProfit)
Add additional rows into Sales_Data.
Confirm that:
- Revenue totals update automatically;
- Profit totals update automatically;
- Named Ranges continue expanding dynamically.
1. What is the main purpose of combining COUNTA with OFFSET?
2. Why are Named Ranges useful when working with OFFSET?
3. What does it mean that OFFSET is a volatile function?
Thanks for your feedback!
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat