Function Problems

Sum Variable Excel Ranges with OFFSET or INDEX

Kushani NimanthikaKushani Nimanthika Nov 12, 2026 869 views

Question details

Create formulas that sum values across ranges with different start and end positions without manually selecting each range.

How to Automatically Sum Variable Excel Ranges
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.
Before you start

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.

Solution 1Recommended

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.

1
Set the anchor and position cells

Place the first value of the source list in C4, the starting position in E4, and the ending position in F4.

2
Enter the variable-range formula

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.

3
Fill the formula down

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 OFFSET for relative start and end positions
How the formula works: E4-1 moves from C4 to the starting position, and F4-E4+1 calculates how many cells to include in the sum.
WPS Spreadsheet formula solution

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. 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. 2. Choose the result cell: Click the first cell where the variable-range total should appear, such as G4.
  3. 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. 4. Confirm the calculation: Press Enter to calculate the first total and verify that the result matches the intended range.
  5. 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.
Use SUM with OFFSET or INDEX and MATCH to total changing row rangesFill formulas down quickly for large calculation tablesOpen and edit Microsoft Excel .xlsx and .xls workbooksUse a familiar spreadsheet layout for seamless formula migration
microsoft office alternative - wps office

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.