How to Sum Selected Cells in Excel (4 Easy Methods)

If you are looking for some special tricks to sum selected cells in Excel, you’ve come to the right place. In Microsoft Excel, there are numerous ways to sum selected cells. In this article, we’ll discuss four methods to sum selected cells. Let’s follow the complete guide to learn all of this.


We will use four effective and tricky methods to sum selected cells in Excel in the following section. This section provides extensive details on four methods. You should learn and apply all of these, as they improve your thinking capability and Excel knowledge.


1. Using SUM Function to Sum Selected Cells in Excel

The following dataset shows sales for different months for a company, with the range of cells, C8: C12 selected to calculate total sales. Our main goal is to sum selected cells. Using the SUM function is the fastest way, to sum up, the selected cells. Let’s walk through the steps to find out how to sum selected cells in Excel.

Using SUM Function to Sum Selected Cells

📌 Steps:

  • Firstly, we will use the following formula in the cell C13:

=SUM(C8:C12)

Here, C8:C12 are the ranges of selected cells for different months, and the sum will be calculated based on these ranges.

  • Now, press Enter.

Using SUM Function to Sum Selected Cells

  • As a consequence, you will get the total sales for selected cells like the following.

Using SUM Function to Sum Selected Cells

Read More: How to Sum Range of Cells in Row Using Excel VBA (6 Easy Methods)


2. Summing Selected Cells Using AGGREGATE Function

Here, we use another method to sum selected cells by using the AGGREGATE function. Here, the AGGREGATE function returns an aggregate in a list or database. Let’s walk through the steps to find out how to sum selected cells in Excel.

Sum Selected Cells Using AGGREGATE Function

📌 Steps:

  • Firstly, we will use the following formula in the cell C13:

=AGGREGATE(9,,C8:C12)

Here, C8:C12 are the ranges of selected cells for different months, and the sum will be calculated based on these ranges.

Here, 9 is the function number, which means the SUM function.

  • Now, press Enter.

Sum Selected Cells Using AGGREGATE Function

  • As a consequence, you will get the total sales for selected cells like the following.

Sum Selected Cells Using AGGREGATE Function


Similar Readings


3. Applying Excel SUBTOTAL Function to Sum Selected Cells

Here, we use another method to sum selected cells by using the SUBTOTAL function. Here, the SUBTOTAL function returns a subtotal in a list or database. Let’s walk through the steps to find out how to sum selected cells in Excel.

Utilizing SUBTOTAL Function in Excel

📌 Steps:

  • Fristly, we will use the following formula in the cell C13:

=SUBTOTAL(9,C8:C12)

Here, C8:C12 are the ranges of selected cells for different months, and the sum will be calculated based on these ranges.

Here, 9 is the function number, which means the SUM function.

  • Now, press Enter.

  • As a consequence, you will get the total sales for selected cells like the following.

Utilizing SUBTOTAL Function in Excel


4. Inserting SUMIF Function to Sum Specific Excel Cells

Here, we use another method to sum selected cells by using the SUMIF function. Here, the SUMIF function adds the cells specified by a given condition or criteria. Now, we are going to calculate the total sales for the months whose sales value was over $4500. Let’s walk through the steps to find out how to sum selected cells in Excel.

📌 Steps:

  • Fristly, we will use the following formula in the cell F5:

=SUMIF(C5:C12,F4)

Here, F4 is the criteria and C8:C12 are the ranges of selected cells for different months, and the sum will be calculated based on these ranges.

  • Now, press Enter.

Applying SUMIF Function in Excel

  • As a consequence, you will get the total sales for selected cells like the following.

Read More: Sum Cells in Excel: Continuous, Random, With Criteria, etc.


Conclusion

That’s the end of today’s session. I strongly believe that from now you may sum selected cells in Excel. If you have any queries or recommendations, please share them in the comments section below.

Don’t forget to check our website Exceldemy.com for various Excel-related problems and solutions. Keep learning new methods and keep growing!


Related Articles

Get FREE Advanced Excel Exercises with Solutions!
Saquib Ahmad Shuvo
Saquib Ahmad Shuvo

Saquib Ahmad Bhuiyan, holding a BSc degree in Naval Architecture & Marine Engineering from Bangladesh University of Engineering and Technology, skillfully integrates engineering expertise with a passion for Excel. He provides solutions to complex issues as an Excel & VBA Content Developer for ExcelDemy Forum. He demonstrates an enthusiastic mindset and adeptness in managing critical situations with finesse, showcasing his commitment to excellence. Apart from creating Excel tutorials, he is interested in Data Analysis with MS Excel, Rhinoceros,... Read Full Bio

2 Comments
  1. What I want to be able to do is select a block of numbers, then right-click and get a few choices on what to show about these – sum, average, median, std deviation, for instance, without putting a formula in a cell. The answer should show up in a separate dialogue window when I select an operation.

    Does Excel do this?

    • Reply Avatar photo
      Musiha Mahfuza Mukta Aug 28, 2023 at 4:21 PM

      Thank you Dave Gilblom, for your comment. Yes, Excel can do this. You should use some VBA codes for this. Below, I am attaching these codes.
      –> In the Module 1 write the following code. Which will return the Sum of selected cells.

      Sub CalculateSum()
          Dim selectedRange As Range
          Dim selectedArea As Range
          Dim cell As Range
          Dim sumValue As Double
          On Error Resume Next
          Set selectedRange = Application.Selection
          On Error GoTo 0
          If Not selectedRange Is Nothing Then
              sumValue = 0
              For Each selectedArea In selectedRange.Areas
                  For Each cell In selectedArea
                      If IsNumeric(cell.Value) Then
                          sumValue = sumValue + cell.Value
                      End If
                  Next cell
              Next selectedArea
             MsgBox "Sum: " & sumValue
          Else
             MsgBox "No valid range selected."
          End If
      End Sub

      –> In the Module 2 write the following code. Which will return the Average of selected cells.

      Sub CalculateSelectedAverage()
          Dim selectedRange As Range
          Dim avgValue As Double
          ' Check if any cells are selected
          If Selection.Cells.count > 0 Then
              ' Set the selected range
              Set selectedRange = Selection
              ' Calculate the average of the selected range
              avgValue = WorksheetFunction.Average(selectedRange)
              ' Display the result in a message box
              MsgBox "The average value of selected cells is: " & avgValue
          Else
              MsgBox "No cells are currently selected."
          End If
      End Sub

      –> In the Module 3 write the following code. Which will return the Median of selected cells.

      Sub CalculateSelectedMedian()
          Dim selectedRange As Range
          Dim cell As Range
          Dim valuesArray() As Double
          Dim medianValue As Double
          Dim i As Long, j As Long
          Dim temp As Double
          ' Check if any cells are selected
          If Selection.Cells.count > 0 Then
              ' Set the selected range
              Set selectedRange = Selection
              ' Copy selected cell values to an array
              ReDim valuesArray(1 To selectedRange.Cells.count)
              i = 1
              For Each cell In selectedRange
                  valuesArray(i) = cell.Value
                  i = i + 1
              Next cell
              ' Sort the values array using bubble sort (simple and not efficient)
              For i = LBound(valuesArray) To UBound(valuesArray) - 1
                  For j = i + 1 To UBound(valuesArray)
                      If valuesArray(j) < valuesArray(i) Then
                          temp = valuesArray(i)
                          valuesArray(i) = valuesArray(j)
                          valuesArray(j) = temp
                      End If
                  Next j
              Next i
              ' Calculate the median based on sorted values array
              If UBound(valuesArray) Mod 2 = 0 Then
                  medianValue = (valuesArray(UBound(valuesArray) \ 2) + valuesArray(UBound(valuesArray) \ 2 + 1)) / 2
              Else
                  medianValue = valuesArray(UBound(valuesArray) \ 2 + 1)
              End If
              ' Display the result in a message box
              MsgBox "The median value of selected cells is: " & medianValue
          Else
              MsgBox "No cells are currently selected."
          End If
      End Sub

      –> In the Module 4 write the following code. Which will return the standard deviation of selected cells.

      Sub CalculateSelectedStdDeviation()
          Dim selectedRange As Range
          Dim cell As Range
          Dim valuesArray() As Double
          Dim sum As Double
          Dim mean As Double
          Dim varianceSum As Double
          Dim stdDeviation As Double
          Dim count As Long
          ' Check if any cells are selected
          If Selection.Cells.count > 0 Then
              ' Set the selected range
              Set selectedRange = Selection
              ' Copy selected cell values to an array
              ReDim valuesArray(1 To selectedRange.Cells.count)
              count = 0
              For Each cell In selectedRange
                  valuesArray(count + 1) = cell.Value
                  sum = sum + cell.Value
                  count = count + 1
              Next cell
              ' Calculate the mean
              mean = sum / count
              ' Calculate the sum of squared differences for variance
              For i = 1 To count
                  varianceSum = varianceSum + (valuesArray(i) - mean) ^ 2
              Next i
              ' Calculate the variance and standard deviation
              If count > 1 Then
                  variance = varianceSum / (count - 1)
                  stdDeviation = Sqr(variance)
              Else
                  variance = 0
                  stdDeviation = 0
              End If
              ' Display the result in a message box
              MsgBox "The standard deviation of selected cells is: " & stdDeviation
          Else
              MsgBox "No cells are currently selected."
          End If
      End Sub

      –> Finally, in the ThisWorkbook >> write the following code.

      Private Sub Workbook_Open()
      Dim cBar As CommandBar
       Set cBar = Application.CommandBars("Cell")
       With cBar.Controls.Add(Type:=msoControlButton, Before:=1)
       .OnAction = "'" & ThisWorkbook.Name & "'!CalculateSum"
       .Caption = "Sum"
        .FaceId = 213
       .Tag = "My_Cell_Control_Tag"
       End With
        With cBar.Controls.Add(Type:=msoControlButton, Before:=1)
       .OnAction = "'" & ThisWorkbook.Name & "'!CalculateSelectedAverage"
       .Caption = "Average"
        .FaceId = 17
       .Tag = "My_Cell_Control_Tag"
       End With
        With cBar.Controls.Add(Type:=msoControlButton, Before:=1)
       .OnAction = "'" & ThisWorkbook.Name & "'!CalculateSelectedMedian"
       .Caption = "Median"
        .FaceId = 50
       .Tag = "My_Cell_Control_Tag"
       End With
       With cBar.Controls.Add(Type:=msoControlButton, Before:=1)
       .OnAction = "'" & ThisWorkbook.Name & "'!CalculateSelectedStdDeviation"
       .Caption = "StdDeviation"
        .FaceId = 2130
       .Tag = "My_Cell_Control_Tag"
       End With
      End Sub

      –> Now, save the code >> press on Run button >> close the Excel file >> re open the file >> select some cells >> right click >> from the Context Menu Bar.

      –> Then, choose the desire operation >> get the answer in MsgBox.

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo