How to Sum Diagonal Cells in a range in Excel?
Last Updated :
06 Sep, 2021
The calculation of matrices is one of the most difficult numerical computation tasks. You may need to add values diagonally in a table when performing mathematical computations. Excel allows you to sum diagonal numbers without having to add the values one by one. We'll go through how to sum cells diagonally down or diagonally up.
Example: The image below shows a matrix & we want to add the elements of the diagonal. Diagonal1 is the right diagonal & Diagonal2 is the left diagonal as its top element is on the left.

Conditional Formatting (On Matrix or Table) :
To do conditional formatting use the following steps :
Step 1: Select the Matrix/Table. Then Go to the home tab & select the conditional formatting option.
Step 2: Choose New Rule.
Step 3: Select: "Use a formula to determine which cells to format" & in the rule description give the format values for the formula. Here we give 1st cell name of the matrix in the formula, i.e., column(B2) - row(B2) (For diagonal)
Step 4: Click on the format. Choose the color, fonts, etc, for formatting & then click on OK.
Step 6: Click on Ok.
You will get your cells formatted.

How to Sum Diagonal Cells in a range in Excel?
A range of cells containing values can be seen in the image below :

Steps to sum the elements diagonally down(from top to bottom) :
Check the cell ranges, say, 'B2' is the first upper-left cell. This is significant because cell 'B2' serves as the start point for the diagonal sum. We SUM the diagonal values down from the first cell 'B2' diagonally right till 'E5'.
Here we want right the diagonal sum, i.e., sum of the cells: B2+C3+D4+E5 .
To do sum of the Left diagonal we will use the formula :
=SUM((COLUMN(Cells Reference)-ROW(Cells Reference) =cellName )*Cells Reference)
into a blank cell , Say F6
Step 1: Go to the cell, where you want to get the result of the addition.
Step 2 : There write : =SUM((COLUMN(B2:E5)-ROW(B2:E5)=M1)*B2:E5)
Step 3 : Press Ctrl + Shift + Enter.
You will get the left diagonal sum. Here you can see the left diagonal sum = 1+1+1+1 = 4
Note: Here M1 contains the difference between columns & rows. Currently, in the above image, it is 0.
If we go to M1 & change its value to 2 :
The addition now is changed to 49 which is the sum of D2 + E3 , i.e., 44+5 = 9. The value 2 of M here indicates the diagonal 2 steps above the current diagonal(in other way we exclude 2 columns & 2 rows)
If we go to M1 & change its value to -1 :
The addition now is changed to 74 which is the sum of B3 + C4 + D5 , i.e., 3+4+67. The value -1 of M here indicates the diagonal 1 step below the current diagonal(in other way we exclude 1 column & 1 row downwards)
Steps to sum the elements diagonally up(from bottom) / The SUM of Diagonal Cells Ascending from Left to Right :
Check the cell ranges, say, 'E2' is the first upper right cell. This is significant because cell 'B5' serves as the start point for the diagonal sum. We SUM the diagonal values down from the first cell 'E2' diagonally right till 'B5'.
Here we want right the diagonal sum , i.e., sum of the cells: E2+D3+C4+B5. To do sum of the right diagonal we will use the formula :
=SUM(Cell Reference*((ROWS(Cell Reference) + Ri)-ROW(Cell Reference)=COLUMN(Cell Reference)-Ci))
into a blank cell , Say F6
Ri => the number of rows in front of the data range's initial cell.
Ci => the number of columns in front of the data range's initial cell.
Example 1: If you have a 5*5 matrix from Row 1 & column A (i.e., From A1 to E5), then if we formula :
= SUM(A1:E5*((ROWS(A1:E5)+0)-ROW(A1:E5)=COLUMN(A1:E5)))
Here Ri = 0, then the no of rows in front of the first cell of the data range is 0, so the addition is done for: A4+ B3 + C2 + D1
Example 2 :
Step 1: Go to the cell, where you want to get the result of the addition.
Step 2 : There write : =SUM(B2:E5*((ROWS(B2:E5)+2)-ROW(B2:E5)=COLUMN(B2:E5)-1))
Step 3 : Press Ctrl + Shift + Enter.
You will get the left diagonal sum. Here you can see the right diagonal sum = 11+14+2+2 = 29
The Diagonal Sum of Values in an Excel table if the number of columns and rows is the same :
In the above example also we have the same number of rows & columns in the cell range. But the thing in the below example differ is that there are different numbers of columns & rows in front of the cell range.
Suppose we want to calculate sum of the elements diagonally up :
Here, Ci = 2 & Ri = 2: as the number of rows in front of the cell reference is 2 & the number of columns in front of the actual cell references is 1.
The Diagonal Sum of Values in the Excel table if the number of columns and rows is different :
In the image below, you can see that the number of rows = 6 & the number of columns = 5 in the cell references.
To find the diagonal sum, follow these steps :
Step 1: Go to the cell, where you want to get the result of the addition.
Step 2: There write : = SUMPRODUCT(((MATCH($A$3:$A$8,$A$3:$A$8,0)-MATCH($B$2:$F$2,$B$2:$F$2,0))=5-4)*($B$3:$F$8))
Step 3: Press Ctrl + Shift + Enter.

Sum of Diagonal Values per column :
The basic formula comes next if we wish to start at the beginning and multiply the total of the numbers or values diagonally by the start column of cell 'B3'. Take note of the number of rows labeled 'pink' in the calculation below.

= SUMPRODUCT(((MATCH($A$3:$A$5,$A$3:$A$5,0)-MATCH($B$2:$D$2,$B$2:$D$2,0))=1-1)*($B$3:$D$5))
= SUMPRODUCT((((ROW($A$3:$A$5)-1)-(COLUMN($B$2:$D$2)-2))=3-1)*($B$3:$D$5))
The Diagonal Sum Down for a specific Number of Columns :
Use the ARRAY formula below to get the sum of the values diagonally down for a certain number of columns. The formula is found in cell 'I11' in the image above, while the condition 'number 3' is found in cell 'G11' in the image above. Only the first 4 columns of the data range are included in this calculation, which is the diagonal sum of values (enter the formula in one line).
= SUM(IF(ROW(OFFSET($B$3:$F$8,0,0,$G$11,G11))-MAX(ROW(OFFSET($B$3:$F$8,0,0,$G$11,G11)))=
COLUMN(OFFSET($B$3:$F$8,0,0,$G$11,G11))-MAX(COLUMN(OFFSET($B$3:$F$8,0,0,$G$11,G11))),
OFFSET($B$3:$F$8,0,0,$G$11,G11),FALSE))
Note that here, in G11, we are specifying the column up to which we want to sum the diagonal elements.
Similar Reads
How to Sum Numbers With Commas in a Single Excel Cell?
In Excel, we can add different comma-separated numbers that are present in the same cell of an excel sheet. Look at the example below, there are 5 comma-separated numbers in cell A2 and we have to sum them up. Comma-separated values in a single cell Let us see the various ways in which we can add th
3 min read
How to Create a Dynamic Chart Range in Excel?
A Dynamic chart range is the range of a data set which automatically updates on any modifications in the original data set. It is beneficial because at some point in time we need to add or delete data from the original data set. So, we want a method to automatically update the chart on performing an
5 min read
How to Calculate the Midrange in Excel?
MS Excel is a spreadsheet developed by the company Microsoft. Excel provides various kinds of functions and we can insert the data in form of rows and columns and perform operations on the data and yield the results we desired. The Midrange of the dataset in other terms can be specified as average o
2 min read
How to Copy Cells on a Diagonal?
Want to copy your MS Excel diagonal data, but cannot complete this copy task? Then you need to know that Excel is a powerful tool, but it has some limitations. One of the limitations of Excel is that we cannot copy cells diagonally, or we could say there is no conventional way to copy cells on a dia
2 min read
How to Sum a Column in Excel: 3 Methods
Knowing how to sum a column in Excel is essential for managing budgets, financial reports, and large datasets. Whether youâre calculating sales totals, adding expenses, or analyzing business data, Excel provides multiple ways to add up a column efficiently. Many users wonder "how to add columns in E
5 min read
How to Create Dynamic Range Based on Cell Value in Excel VBA?
Dynamic ranges in excel VBA provide us with the flexibility to define ranges beyond the specific values. The dynamic range enables the program to perform transformation and data management steps with ease without the worry of changing the range of the data set. The dynamic range in excel VBA promote
3 min read
How to Calculate the Interquartile Range in Excel?
In statistics, the five-number summary is mostly used as it gives a rough idea about the dataset. It is basically a summary of the dataset describing some key features in statistics. The five key features are :Minimum value: It is the minimum value in the data set.First Quartile, Q1: It is also know
3 min read
How to Calculate Mean, Median and Mode in Excel
Understanding the concepts of mean, median and mode in Excel can grow your mathematics and Excel skills. Understanding how to calculate mean in Excel, work out mean on Excel, how to calculate median in Excel, find median in Excel, and calculate mode in Excel can revolutionize how you interpret data.
9 min read
How to Create Anti-Diagonal Matrix in R
In this article, we will discuss how to create an anti-diagonal matrix with its working example in the R programming language. Anti-Diagonal Matrix: The anti-diagonal matrix is a square matrix where all entries are zero except for those on the anti-diagonal. That is to say, the diagonal goes from th
2 min read
How to sum leading diagonal of table in R
Working with tables and matrices in R is a common task, especially when dealing with data analysis and manipulation. One common operation is summing the elements of the leading diagonal (also known as the main diagonal) of a matrix. This article will guide you through the process of summing the lead
3 min read