Excel Formula to Sum Values After the Last Non-7 Entry
Question details
The user needs an Excel formula to calculate the sum of a range starting from the last occurrence of a cell that does not equal a specific value (e.g., 7) through the end of that range.

- Product
- Spreadsheets
- Device & OS
- not provided
- Scenario
- Calculating a conditional sum based on the position of the last specific non-matching value in a horizontal dataset.
- Observed behavior
- The user wants to dynamically identify the last cell that is not equal to 7 in a range (like C4:J4) and sum all values from that point to the end of the range.
Ensure your spreadsheet software supports dynamic array functions like FILTER, XLOOKUP, and SEQUENCE, as these are required for this advanced calculation.
Use SUM, FILTER, and XLOOKUP Functions
This method dynamically finds the position of the last non-7 entry and filters the array to sum only the values from that point forward.
This formula combines several modern spreadsheet functions. XLOOKUP is used to search in reverse (from right to left) to find the position of the last value that isn't 7. FILTER then isolates the range starting from that column, and SUM calculates the total of those isolated values.
Click on the cell where you want the final sum result to appear.
Type the following formula into the formula bar: =SUM(FILTER(C4:J4,COLUMN(C4:J4)>=XLOOKUP(TRUE,C4:J4<>7,SEQUENCE(,COLUMNS(C4:J4)),1,-1)))
Change instances of 'C4:J4' in the formula to match the actual row and column range of your specific dataset.
Press the Enter key to execute the formula and view the sum of the filtered range.

Calculate Complex Formulas for Free with WPS Spreadsheet
WPS Office provides robust support for advanced dynamic array functions like XLOOKUP, FILTER, and SEQUENCE, allowing you to solve complex data analysis problems quickly and easily.
- 1. Open your workbook: Launch WPS Spreadsheet and open the file containing your dataset.
- 2. Select the destination cell: Click on the cell where you want the conditional sum to be calculated.
- 3. Enter the dynamic formula: Type your combined SUM and XLOOKUP formula and press Enter to instantly get the results.
- 4. Save with seamless compatibility: Save your work in the standard .xlsx format, ensuring perfect compatibility with Microsoft Office users.

Frequently Asked Questions
What if my data is in a column instead of a row?
If your data is arranged vertically (for example, C4:C20), you need to change the COLUMN function to ROW, change COLUMNS to ROWS, and adjust the range references accordingly in the formula.
Why does the formula return a #NAME? error?
Functions like FILTER, XLOOKUP, and SEQUENCE are modern dynamic array functions. If you are using an older version of spreadsheet software that does not support them, the system will not recognize the function names and will return a #NAME? error. Upgrading to the latest WPS Office resolves this.
Can I change the specific value from a number to text?
Yes, you can modify the condition. Simply replace the '7' in the 'C4:J4<>7' portion of the formula with your desired text enclosed in quotation marks, such as 'C4:J4<>"Completed"'.




