Excel Formula for Working with Positive and Negative Numbers

In this Excel tutorial, you will learn how to work with positive and negative numbers using Excel Formula. We will discuss how to do these using Excel formulas:
– Convert Negative Numbers to Positive Numbers
– Identify Positive and Negative Numbers
– Count Positive and Negative Numbers
– Sum Positive and Negative Numbers
– Separate Positive and Negative Numbers
– Swap Between Positive and Negative Numbers

Note: While writing this article, I used Microsoft Excel 365. But all these methods can be applicable in any Excel version.

Various fields like finance, budget-making, scientific research, and project management must frequently handle positive and negative numbers. For example, Inventory management relies on tracking incoming stock (positive) and outgoing stock (negative) accurately. In scientific research, data often includes both positive and negative values. Excel offers many functions like IF, COUNTIF, SUMIF, MAX, and MIN for working with positive and negative numbers.

Overview of Excel Formula for Working with Positive and Negative Numbers

Overview of Excel Formulas for Working with Positive and Negative Numbers


1. Converting Negative Numbers to Positive Numbers Using Excel Formulas

Converting negative numbers to positive numbers in Excel can be done using the Excel IF Function, Excel ABS function, and Excel VBA code.

1.1 Using Excel IF Function

In this section, you will learn how to convert negative into positive values using the IF function.

Suppose, in the following image, you see some negative values in the range B5:B13 under the heading Negative Number. I will convert these negative values and store them in column C, named Positive Number, using the Excel IF function.

Dataset to Convert Negative Number to Positive Number Using Excel Formulas

Follow these steps:

Step 1: Select cell C5 => Insert the following formula:

=IF(B5<0, -B5, B5)

Select cell C5 and insert the intended formula

Step 2: Press the Enter or Tab button, and we will find -10 is converted to 10.

After pressing Enter, you will see the output

Step 3: Hover the cursor over the bottom right corner of cell C5 => You will see the Fill Handle icon.

Hover the mouse cursor over the right bottom corner of cell C5 to find the Fill Handle icon

Step 4: Drag the Fill Handle icon to cell C13 to convert the rest of the negative values to positive values.

Converting Negative Number to Positive Number Using IF Function

Note

You can also double-click on the Fill Handle icon to copy the formula to other cells in the column instead of dragging.


1.2 Using Excel ABS Function

We can also convert the negative values to positive values in Excel using the ABS function.

Excel ABS function converts negative values to positive values and keeps the positive values unchanged.

Follow these steps:

Step 1: Select cell C5 => Insert the below formula:

=ABS(B5)

Select cell C5 and insert the equation of ABS Function

Step 2: Press the Enter button, and we will see -10 is converted to 10.

After pressing Enter, you will see the intended output

Step 3: Likewise, find the Fill Handle icon by hovering over the button in the right corner of cell C5.

Hover the mouse cursor over the right bottom corner of cell C5 to find the Fill Handle icon

Step 4: Drag the Fill Handle icon to cell C13 to convert the rest of the negative to positive values.

Converting Negative Number to Positive Number Using ABS Function


1.3 Using Excel VBA User-Defined Function

We can create an Excel VBA User-defined function to convert negative to positive values.

A user-defined function will be helpful when working on automation tasks or VBA projects.

Follow these steps:

Step 1: Navigate to the Developer tab => In the Code group, you will find the Visual Basic command.

Navigate to Developer and click on Visual Basic

Step 2: Click on Visual Basic to open the VBA Editor window => Hover over Insert => Click on Module => Paste the following code in the module, and Save.

Function ConvertToPositive(ByVal num As Double) As Double

    If num < 0 Then
        ConvertToPositive = -num
    Else
        ConvertToPositive = num
    End If

End Function

Insert the given code in module and Save

Step 3: Return to the sheet and select cell C5 => insert the following equation:

=ConvertToPositive(B5)

Insert the given equation with User-defined function in cell C5

Step 4: Press the Enter key => You will see -10 is converted to 10.

After pressing Enter, you will see 10 in cell C5

Step 5: Find the Fill Handle icon by hovering over the button in the right corner of cell C5.

Hover the cursor over the right bottom corner of cell C5 to see the Fill Handle icon

Step 6: Double-click on the Fill Handle icon to copy the formula in other cells.

Converting Negative Number to Positive Number Using VBA User-Defined Function

Note

If you need to convert the positive to negative numbers, you can use the Excel IF function.

Excel Formula to convert positive to negative values:

=IF(B5>0, -B5, B5)

Converting Positive Number to Negative Number Using Excel Formulas

Read More: How to Convert Negative Value to Positive in Excel Using Formula


2. Identifying Positive and Negative Numbers Using IF Function

We can identify whether a number is positive or negative using the Excel IF function.

Assume, like the following image, we have some values in the range B5:B13 under the Number column. We will identify them and put decisions in the Status column.

Dataset to Identify Positive and Negative Numbers Using Excel Formulas

Follow these steps:

Step 1: Select the cell C5 => insert the following formula:

=IF(B5>0, "Positive", IF(B5<0, "Negative", "Zero"))

Insert the given excel formula in cell C5

Step 2: Press the Enter key => You will see Positive as 7 is a positive number.

After pressing Enter, you will get Positive in cell C5

Step 3: Hover over the cursor in the bottom right corner to find the Fill Handle icon.

Hover the mouse cursor over the right bottom corner of cell C5 to find the Fill Handle icon

Step 4: Double-click on Fill Handle to display the proper status of other numbers.

Identifying Positive and Negative Numbers Using IF Function

Read More: How to Make Negative Numbers Red in Excel


3. Counting Positive and Negative Numbers Using COUNTIF Function

Throughout this context, you will learn how to count positive and negative numbers using the COUNTIF function.

Assume I have some numbers in the range B5:B13 under the Number column. In cell D6, I will count the positive numbers and store the value. For negative numbers, I will use cell D8.

Dataset to Count Negative and Positive Numbers Using Excel Formulas

First, we will count the positive number within the range B5:B13.

Follow these steps:

Step 1: Select cell D5 => Insert the following formula:

=COUNTIF(B5:B13, ">0")

Select cell D5 and insert the intended formula

Step 2: Press the Enter key => You will see 3 in D5, as there are only three positive numbers.

Hit Enter and see total count of Positive Numbers

Now, we shall count the negative numbers using Excel Formula.

Follow these steps:

Step 3: Choose cell D8 => Insert the following formula:

=COUNTIF(B5:B13, "<0")

Select cell D8 and insert the given formula

Step 4: Press the Enter key => You can see 5 in D8 as there are five negative numbers.

Press Enter and you can see the total count of Positive and Negative Numbers

Read More: How to Sum Negative and Positive Numbers in Excel


4. Summing Positive and Negative Numbers with SUMIF Function

Here, you will learn how to sum positive and negative numbers using the SUMIF function.

I will use the same dataset. However, in cells D5 and D8, I will store the summation of positive and negative numbers, respectively.

Dataset to Sum Negative and Positive Numbers Using Excel Formulas

First, we will find the summation of the positive numbers within the range B5:B13.

Follow these steps:

Step 1: Select cell D5 => Insert the following formula:

=SUMIF(B5:B13, ">0")

Select cell D5 and insert the intended formula to sum positive numbers

Step 2: Press the Enter key => You will see 41 in cell D5.

Hit Enter and see the sum of positive numbers

Now, we shall determine the summation of the negative numbers.

Follow these steps:

Step 3: Select cell D8 => Insert the following formula:

=SUMIF(B5:B13, "<0")

Select cell D8 and insert the intended formula to sum positive numbers

Step 4: Press Enter => You will see -108 in cell D8.

Press Enter and you can see the sum of Positive and Negative Numbers

Read More: How to Put Negative Percentage Inside Brackets in Excel


5. Separating Positive and Negative Numbers Using Excel Formulas

We can separate positive and negative numbers by combining the MAX and MIN functions. Separating of positive and negative numbers can also be done by using the IF function.

5.1 Using MAX and MIN Functions

Here, you will learn how to separate positive and negative numbers by combining the MAX and MIN functions.

Suppose I have some numbers in the range B5:B13 under the Number title. I will keep all the positive and negative numbers in columns D and E under the title Positive Number and Negative Number, respectively.

Dataset to Separate Positive and Negative Numbers Using Excel Formulas

First, we will separate all the positive numbers using the Excel MAX function.

Follow these steps:

Step 1: Choose cell D5 => Insert the following formula:

=MAX(B5,0)

Choose cell D5 and insert the given formula

Step 2: Press Enter => You will see 7 in cell D5.

Hit Enter and you will see the result for D5

Step 3: Find the Fill Handle icon by hovering the cursor over the bottom right corner of cell D5.

Find the Fill Handle icon of cell D5

Step 4: Double-click on Fill Handle to copy the formula in other cells => You can see positive numbers are separated.

Double-click on the Fill Handle icon to see the intended result

Now, we will separate the negative numbers.

Follow these steps:

Step 5: Select cell E5 => Insert the following formula:

=MIN(B5,0)

Choose cell E5 and insert the given formula

Step 6: Press Enter => You will 0 in cell E5.

Hit Enter and you will see the result for E5

Step 7: Find the Fill Handle by hovering the bottom right corner of cell E5.

Find the Fill Handle icon of cell E5

Step 8: Double-click on Fill Handle to copy the formula to other cells => You can see the negative numbers are separated as well.

Hit Enter and You see the Positive and Negative Numbers are separated in two columns

Note

As you can see, separating positive and negative numbers by using MAX and MIN functions inserts a 0 in the cells. If you want to avoid these extra 0, you must go through the following method. Using the IF function will overcome this issue.


5.2 Using IF Function

We can also separate positive and negative numbers by using the IF function. Unlike the previous method, we will avoid the extra 0 here, and thus, the sheet looks better.

I am using the same dataset for better understanding.

Dataset to separate positive and negative numbers using IF function

Firstly, we will separate positive numbers using the Excel IF Function. 

Follow the steps:

Step 1: Select cell D5 => Insert the following formula:

=IF(B5>0,B5,"")

Choose cell D5 and insert the given formula

Step 2: Press Enter => You see 7 in cell D5.

Hit Enter and you will see the result

Step 3: Hover the mouse cursor over the bottom right corner of cell D5 to find the Fill Handle.

Find the Fill Handle icon of cell D5

Step 4: Drag the Fill Handle icon to cell E13 => You will see the positive numbers are separated and there are no extra zeros.

Drag the Fill Handle icon to D13 to separate positive numbers

Now, we shall separate negative numbers.

Follow the steps.

Step 5: Choose cell E5 => Insert the following formula:

=IF(B5<0,B5,"")

Insert the given formula in cell E5

Step 6: Press Enter => You will see that the cell E5 is empty.

Press Enter and you can see that the E5 cell is empty

Step 7: Find the Fill Handle icon by hovering over the bottom right of cell E5:

Find the Fill Handle icon of cell E5

Step 8: Drag the Fill Handle icon to cell E13 => You will see negative numbers are separated and there are no extra zeros.

Double-click on Fill Handel and you can see the Positive and Negative Numbers are separated

Read More: How to Add Brackets to Negative Numbers in Excel


6. Swapping Between Positive and Negative Numbers By Multiplying Negative 1

Swapping a positive to a negative number and a negative to a positive number can be done by multiplying -1.

Assume I have some numbers in the range B5:B13 under the Number titled. And their current status in the range C5:C13, whether a number is positive, negative or zero. I will swap these numbers and put them in the range E5:E13 under the Swapped Number title.

Dataset to Swap Between Positive and Negative Numbers By Multiplying Negative 1

Follow these steps:

Step 1: Select cell E5 => Insert the following formula:

=B5 * -1

Choose cell E5 and insert the given formula

Step 2: Press Enter => You will see 7 is turned into -7 in cell E5.

After pressing Enter, you will see negative 7 as output

Step 3: Find the Fill Handle icon by hovering over the bottom right of cell E5.

Find the Fill Handle icon of cell E5

Step 3: Double-click on Fill Handle to copy the formula down => You can see all the numbers are swapped.

Drag the Fill Handle icon to cell E13 and see Positive and Negative Numbers are swapped

Read More: How to Move Negative Sign at End to Left of a Number in Excel


Download Practice Workbook

I have practiced all the methods within the .xlsx file except for VBA. While using VBA, I worked in the .xlsm file.


So, in this Excel tutorial, We present several Excel formulas for working with positive and negative numbers. For example, IF, ABS and VBA for converting positive to negative numbers, IF, COUNTIF and SUMIF for identifying, counting, and summing positive and negative numbers, and swapping and separating positive and negative numbers using Excel formulas. Do not hesitate to leave a comment if you have any questions.


Related Articles


<< Go Back to Negative Numbers in Excel | Number Format | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Lutfor Rahman Shimanto
Lutfor Rahman Shimanto

Lutfor Rahman Shimanto, BSc, Information Technology, Jahangirnagar University, Bangladesh, has worked with the ExcelDemy project for over a year. He has written 50+ articles and provided solutions of 100+ comments for ExcelDemy. Currently, he works as an Excel & VBA Developer and provides support and solutions in the ExcelDemy Forum. He has solved 100+ ExcelDemy Forum problems. His work and learning interests are in developing various Excel & VBA and Desktop applications. Outside of work, he enjoys Chess... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo