Formula Errors

Calculate a Year-to-Date Total by Period in Excel

Elise WilliamsElise Williams Nov 27, 2026 869 views

Question details

Calculate a year-to-date total through the period number entered in cell A2.

Calculate a Year-to-Date Total by Period in Excel
Product
Microsoft Excel
Device & OS
not provided
Scenario
Period values are arranged across a row, and the user wants the total to update when the selected period changes.
Observed behavior
The desired total includes period 1 through the period specified in A2.
Before you start

Arrange the 12 period values in chronological order across C5:N5. Enter a whole number from 1 through 12 in A2, and choose an output cell outside C5:N5.

Solution 1Recommended

Use SUM and INDEX to total through the selected period

Use this formula when period values are in consecutive columns and A2 contains the ending period number.

INDEX selects the ending cell within C5:N5, and SUM adds the values from C5 through that cell.

1
Enter the period number

Select A2 and enter a whole number from 1 through 12.

2
Enter the formula

Select an empty cell outside C5:N5, such as O5, and enter =SUM(C5:INDEX(C5:N5,1,A2)).

3
Check the result

Press Enter. With 1 in A2, the formula totals C5; with 4 in A2, it totals C5:F5.

Use SUM and INDEX to total through the selected period
Adjust the range for your worksheet: If the period values are elsewhere, replace C5:N5 with their consecutive range and replace the first C5 with the first cell in that range. Keep A2 within the number of periods available.
Calculate period totals in WPS

Calculate year-to-date totals in WPS Spreadsheets

Use the same SUM and INDEX formula in WPS Spreadsheets to total consecutive periods through the number selected in A2.

  1. 1. Open your spreadsheet: Open WPS Spreadsheets and use Open to select your workbook.
  2. 2. Set up the periods: Place the period values in C5:N5 and enter a period number from 1 through 12 in A2.
  3. 3. Add the formula: Select O5 or another empty cell outside the period range and enter =SUM(C5:INDEX(C5:N5,1,A2)).
  4. 4. Calculate and save: Press Enter to calculate the total, then use File > Save to save the workbook.
Update the year-to-date total by changing one period numberOpen and save Microsoft Excel XLSX and XLS filesUse familiar spreadsheet formulas and a familiar interfaceWork with spreadsheets for free
microsoft office alternative - wps office

Frequently Asked Questions

How does the formula know which period to stop at?

INDEX(C5:N5,1,A2) selects the cell at the position specified in A2. SUM then totals the range from C5 through that cell.

What happens if I enter 4 in A2?

The formula totals C5:F5, covering periods 1 through 4.

Can I use a different range for the period values?

Yes. Replace C5:N5 with the consecutive cells containing your periods, and replace the first C5 with the first cell of that range. Enter a period number in A2 that does not exceed the number of columns.

Why does the formula return an error for my period number?

Check A2 and enter a whole number from 1 through 12 for the C5:N5 range. A number beyond the available columns can cause a reference error.