Sum Variable Excel Ranges with OFFSET or INDEX
Question details
Create formulas that sum values across ranges with different start and end positions without manually selecting each range.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Thousands of rows require totals based on variable starting and ending positions listed in worksheet cells.
- Observed behavior
- The required sum range changes for each calculation, making manual range selection impractical.
Confirm that the start and end positions are in the same order and refer to entries in the lookup column. Ensure the values to be summed are stored in a single contiguous values column.
Use SUM with OFFSET for relative start and end positions
Use this method when the start and end values are numeric positions relative to a fixed first value cell.
OFFSET builds a range beginning at the specified offset from the anchor cell, and SUM returns the total for the calculated range. It is convenient for fill-down calculations, although OFFSET is a volatile function in large workbooks.
Place the first value of the source list in C4, the starting position in E4, and the ending position in F4.
In the results cell, enter =SUM(OFFSET($C$4,E4-1,,F4-E4+1)). The $C$4 reference remains fixed, while E4 and F4 change for each row.
Select the formula cell and drag the fill handle down, or use Home > Fill > Down, to calculate each row's variable range total.

Use SUM with INDEX and MATCH for a nonvolatile variable range
Use this option when start and end values must be matched against labels or positions in a separate lookup column.
Calculate Variable Range Totals in WPS Spreadsheet
WPS Spreadsheet lets you build dynamic SUM formulas with OFFSET, INDEX, and MATCH, then fill them down to calculate changing ranges across thousands of records. Its familiar spreadsheet interface makes moving existing Excel formulas straightforward.
- 1. Open the worksheet in WPS Spreadsheet: Launch WPS Office, select Spreadsheets, and open the Excel workbook containing the start, end, and values columns.
- 2. Choose the result cell: Click the first cell where the variable-range total should appear, such as G4.
- 3. Enter a dynamic range formula: Type =SUM(OFFSET($C$4,E4-1,,F4-E4+1)) for relative positions, or use the INDEX and MATCH formula when matching labels in a lookup column.
- 4. Confirm the calculation: Press Enter to calculate the first total and verify that the result matches the intended range.
- 5. Apply the formula to all rows: Drag the fill handle from the result cell down the column to calculate totals for the remaining start and end positions.

Frequently Asked Questions
Why does the OFFSET formula use E4-1?
The anchor cell is C4, which represents position 1. Subtracting 1 from the starting position converts that position into the number of rows OFFSET must move from C4.
What happens if the end position is smaller than the start position?
The height argument, F4-E4+1, becomes zero or negative and the formula will return an error. Make sure every end position is equal to or greater than its start position.
When should I use INDEX and MATCH instead of OFFSET?
Use INDEX and MATCH when the start and end inputs are labels in a lookup column, such as B4:B13, or when you want a nonvolatile formula for a large workbook.
Can I copy the variable range formula down to thousands of rows?
Yes. Keep the source range anchor absolute, such as $C$4 or $C$4:$C$13, and leave the start and end references relative, such as E4 and F4, before filling down.
Will these formulas work in WPS Spreadsheet?
Yes. WPS Spreadsheet supports SUM, OFFSET, INDEX, and MATCH formulas and can open Excel .xlsx and .xls files containing these calculations.




