Sum only positive numbers

To sum only positive numbers in a specified range you can apply the Excel SUMIF function

Example: Sum only positive numbers

Sum only positive numbers

METHOD 1. Sum only positive numbers

EXCEL

=SUMIF(C5:C11,">0")
The formula uses the Excel SUMIF function to sum only the positive numbers from the specified range (C5:C11).

METHOD 1. Sum only positive numbers using VBA

VBA

Sub Sum_only_positive_numbers()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'apply the formula to sum only positive numbers
ws.Range("E5") = Application.WorksheetFunction.SumIf(ws.Range("C5:C11"), ">0")

End Sub

OBJECTS
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
PREREQUISITES
Worksheet Name: Have a worksheet named Analyst.
Range: Ensure that the data you want sum and test against is captured in range ("C5:C11").
ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("E5") in the VBA code to any cell in the worksheet, that doesn't conflict with the formula.
Range: Select the range that you want to sum and test against by changing the range ("C5:C11") to any range in the worksheet, that doesn't conflict with the formula.

Explanation about the formula used to sum only positive numbers

EXPLANATION

EXPLANATION
To sum only positive numbers in a specified range you can apply the Excel SUMIF function.
FORMULA
=SUMIF(range, ">0")

ARGUMENTS
range: The range of cells you want to sum from and test the criteria against.
">0": The criteria that is used to determine which of the cells, from the specified range, should be summed.