Close Menu
Computing.net
    Facebook X (Twitter) Instagram
    Computing.netComputing.net
    • News
      1. AI
      2. Crypto
      3. Gaming
      4. Hardware
      5. Security
      6. Software
      7. View All

      Anthropic’s COBOL Automation Tool Triggers IBM Stock Plunge and Crypto Market Decline

      February 24, 2026

      AI Trading Bot Loses $441K in Crypto After Decimal Point Mistake

      February 23, 2026

      Tesla (TSLA) Stock: Goodbye Sedans, Hello Robots in Dramatic Production Shift

      January 29, 2026

      Palantir Technologies (PLTR) Stock: Why Bears May Be Wrong About Valuation Concerns

      January 29, 2026

      SUI Token Rallies 40% Following Major Staking Event and CME Futures Announcement

      May 12, 2026

      Chainlink (LINK) Surges to $10.40 as Network Activity Hits Eight-Month Peak

      May 12, 2026

      Dogecoin Whales Ramp Up Accumulation as DOGE Eyes Critical Breakout Levels

      May 12, 2026

      Bitcoin Holds $81K While Burry Flags Nasdaq Bubble and Oil Surges Past $105

      May 12, 2026

      Hamster Kombat: Unraveling TON’s Gaming Phenomenon

      August 7, 2024

      W-Coin: Exploring the Latest Telegram Tap-to-Earn Phenomenon

      August 7, 2024

      Hamster Kombat: 300 Million Players & Counting, HMSTR Token Airdrop Soon!

      July 31, 2024

      Hamster Kombat Developers Work with TON Team on Airdrop Solution

      July 30, 2024

      Nothing Expands Product Line with New AI Feature & Phone Update

      July 31, 2024

      Security Audit Reveals Concerns in Atari’s Blockchain Game on Base

      August 6, 2024

      SideWinder Group Targets Maritime Facilities in New Cyber Espionage Campaign

      July 30, 2024

      OAuth Implementation Flaw Exposes Millions of Websites to XSS Attacks

      July 30, 2024

      Hamster Kombat Players Face Growing Cybersecurity Threats

      July 25, 2024

      Anthropic’s COBOL Automation Tool Triggers IBM Stock Plunge and Crypto Market Decline

      February 24, 2026

      Cookie Crumble: Google Halts Plans to Eliminate Third-Party Cookies in Chrome

      July 23, 2024

      Big Brother is Watching: Apple’s Creepy New Ad Urges iPhone Users to Ditch Chrome

      July 23, 2024

      Nvidia Stock Soars to New Record at $219.44 Ahead of May 20 Earnings

      May 12, 2026

      Rocket Lab Shares Surge Past $120 Following Wave of Analyst Upgrades

      May 12, 2026

      GM Shares Decline Following 600 IT Layoffs Amid Strategic AI Workforce Transformation

      May 12, 2026

      SES Delivers €847M Q1 Performance as Intelsat Integration and Aviation Deals Fuel Expansion

      May 12, 2026
    • How To

      Batch Files: Tokens and Delimiters (FOR Loops)

      July 31, 2024

      Types of Ethernet Cabling & Electrical Low Voltage Wiring

      July 9, 2024

      What You Should Know About .JSON File Extension

      January 10, 2023

      Bkup File Extension

      November 19, 2022

      HEIC File Extension

      November 19, 2022
    • Office
      1. Excel
      2. Google Sheets
      3. View All

      How to Convert Column List to Comma Separated List in Excel

      July 24, 2024

      How to Find the Last Monday of the Month in Excel

      July 24, 2024

      Convert Bytes to MB or GB in Excel: 3 Methods!

      July 24, 2024

      How to Remove Characters from Right in Excel

      July 30, 2023

      How to Subtract in Google Sheets: Complete Guide

      July 31, 2024

      Bullet Points in Google Sheets

      January 20, 2022

      Sort by Date in Google Sheets

      January 18, 2022

      Google Sheets Timestamp

      January 17, 2022

      How to Subtract in Google Sheets: Complete Guide

      July 31, 2024

      How to Convert Column List to Comma Separated List in Excel

      July 24, 2024

      How to Find the Last Monday of the Month in Excel

      July 24, 2024

      Convert Bytes to MB or GB in Excel: 3 Methods!

      July 24, 2024
    • Answers
    • About
    • Contact
    Facebook X (Twitter)
    Computing.net
    Excel

    Counting Negative Numbers in Excel

    Denise ElizabethBy Denise ElizabethJanuary 21, 2022
    Twitter LinkedIn Email Telegram
    Counting_Negative_numbers
    Twitter LinkedIn Email Telegram

    Have you been faced with the task of counting the number of values on a worksheet based on a specified criterion on Excel, specifically Counting Negative Numbers in Excel?

    Today we will see how to Count the number of Negative Values (or Numbers) in an Array of Data consisting of both positive and negative values on Excel using:

    1. A function
    2. Visual Basic Application Code

    For the purpose of this tutorial, we will be using the table shown below to understand how to carry out this task.

    This table shows the average temperature of seven cities in the month of April and May and our task will be to count the number of Negative temperatures. 

    counting negative numbers excel 1

    Before we proceed, let us define some terminologies which you will come across in the course of this tutorial.

    • Negative Numbers: Numbers with a ‘-‘ (minus) sign in front of the Value. Eg. -5, -9.2.
    • Range: A collection of selected cells with an upper reference (the first selected cell on the left) and a lower reference (the last selected cell on the right). In our example the range is C3:D9. From the image below, you would discover that our range cuts through two columns (Column C and Column D) and seven row (Row 3,4,5,6 and 7). You will notice that Cell C3 is the Upper reference and Cell D9 is the lower reference in the range.
      counting negative numbers in excel 2
    • Criteria: This defines the condition that tells the function which cell to count. For example, if the criteria is set at less than 0, the function counts all values less than 0. The Criteria can be a number, text string, or a reference cell
    • Function: This is a pre-established formulas that performs calculations by using specific values, called arguments, in a particular order E.g., AVERAGE, COUNT, COUNTIF
    • Condition: This is an expression that evaluates if a statement is TRUE or FALSE
    • VBA – This is an acronym for Visual Basic Application. It is an event driven programming language
    • Sub: This is a short for Subroutine. A subroutine is primarily a piece of code that executes a specific task described in the code
    • Dim: This is an acronym for Declare in Memory. It is used to declare a variable to a specific data type
    • Set – This is a statement which is used to assign a value to an object

    Contents:

    Toggle
    • A: USING A FUNCTION (=COUNTIF (range,criteria)) for Counting Negative Numbers in Excel
    • B: USING A VISUAL BASIC APPLICATION CODE
    • USING VBA FOR A STATIC RANGE
    • Using VBA FOR A DYNAMIC RANGE
    • Conclusion

    A: USING A FUNCTION (=COUNTIF (range,criteria)) for Counting Negative Numbers in Excel

    Step 1: Navigate to a blank cell where you wish to have your result displayed

    Step 2: Click on the Cell (In this tutorial, we have selected Cell C10 as our result cell) 

    Step 3: Type in an equal to symbol (‘=’)

    Step 4: Type in the COUNTIF function

    Step 5: Insert an Opening bracket (‘(‘) 

    Step 6: Select the range. (In our example the range is C3:D9)

    Step 7: A highlighted reference to Cell C3 to Cell D9 will appear

    Step 8: Insert a Comma sign (‘,’)

    Step 9: Input the condition. In our example the condition is “<0”.

    Note: When inputting a condition that has a text within, always use a Double Quotation mark. Excel uses the text embedded and discards the quotes while running.

    Step 10: Close the bracket

    Step 11: Press the ENTER key.

    You should see your result appear in the designated cell.

    counting negative numbers using excel 3

    You can practice other conditions (such as “>0”, 1, etc) using the same dataset. 

    B: USING A VISUAL BASIC APPLICATION CODE

    Counting 

    VBA allows you to easily automate various activities in Excel.

    This is done by writing a program from the backend.

    I know this sounds like a programmer’s task but trust me when I say it’s very easy.

    Firstly, we need to be sure that the “Developer” Tab on your MS Excel ribbon is activated. If this isn’t the case, simply

    • Go to File
    • Click on Options from the excel dialog box
    • Click on the Customize Ribbon in the left pane
    • Check the Developers option on the right pane
    • Click OK.

    Now let’s get started with VBA!

    Here I will show you have to write a program for a static range and a dynamic range

    USING VBA FOR A STATIC RANGE

    This method is only used when the dataset range is static.

     If a change in the range is effected, the new range parameters must be updated in the program.

    Let’s see how this is done!

    Step 1: Click on the Developer tab on the excel ribbon

    Step 2: Select the Visual Basic Icon on the Left

    The VBA Window opens.

    USING A VISUAL BASIC APPLICATION CODE

    Step 3: Click Insert and Select Module

    VBA window

    A blank Module window is created.

    Step 4: Copy and paste the code below

    Public Function Number_of_negatives() As Integer
    Dim ws As Worksheet
    Dim myrange As Range
    Dim totalcells As Integer
    Dim Cell As Range
    Set myrange = Range("C3:D9")
    totalcells = 0
    For Each Cell In myrange
        If Cell.Value < 0 Then
        totalcells = totalcells + 1
        End If
    Next
    Number_of_Negative = totalcells
    End Function

    Let me quickly explain what we are trying to achieve with this code

    This is a For Loop program. During the code execution an analysis of all cells within the range is carried out.

    For every time a cell is checked against the “<0” condition, if the response is TRUE, it documents it and moves to the next cell. 

    Step 5:   Close your VBA window

    Step 6: Navigate to the Cell you wish to display your answer and type in =( equal to), followed by the Subroutine name (in our example this is Number_of_negatives), opening and closing brackets.

    You will discover that the subroutine name displays as a function on Excel.

    Step 7: Click OK

    Step 8: The answer is displayed

    Using VBA FOR A DYNAMIC RANGE

    Step 1: Click on the Developer tab on your MS Excel ribbon

    Step 2: Select the Visual Basic Icon on the Left

    The VBA Window opens.

    VBA

    Step 3: Click Insert and Select Module

    VBA FOR A DYNAMIC RANGE

    A blank Module window is created.

    Step 4: Copy and paste the code below

    Sub Count_negative_temperature()
    Dim ws As Worksheet
    Dim myrange As Range
    Dim Cell As Range
    Set ws = Application.ActiveSheet
    Set myrange = Application.Selection
    Set Cell = Application.InputBox(Title:="Designated Cell Location", _
    Prompt:="What Cell do you Want your Answers?", _
    Type:=8)
    Cell.Value = Application.WorksheetFunction.CountIf(myrange, "<0")
    End Sub

    Let me quickly explain what we are trying to achieve. 

    This subroutine will analyze all cells within a selection on any worksheet and count the number of negatives within.

    Step 5: Close the VBA window and return to the worksheet

    Step 6: Highlight the Range of cells you wish to analyze. In our example the range is “C3:D9” 

    Step 7: Click on the Developer tab on the excel ribbon

    Step 8: Select the Macros Icon on the Left

    Step 9: A Micros dialog box pops out

    Step 10: In the “Macros name” field, Select the Subroutine name you just created on your VBA (In our example, the subroutine is ‘Count_negative_temperature’

    Step 11: In the “Macros In” field, select where (what worksheet) you want the program to be applied. In our example, we want the program to run in the excel document called Counting_Negative_numbers

    Step 12: Click on the Run button

    Counting_Negative_numbers

    Step 13: A prompt pops out requesting you to select the Cell where you wish to display your answer

    Step 14: Navigate to the Cell you wish to display your answer and select it. Alternatively, if you already know the Cell label, simply follow this syntax ???? ($Columnname$Rownumber for example $C$13)

    Note: If you want to display your result in more than one cells, simple hold down your Shift key, while you select your desired cells.

    Step 15: Click OK

    Step 16: You answer is displayed on the designated Cell(s)

    Just in case you wish to add you Macro to your quick access bar, you can easily follow the following outlined steps.

    Step 1: Click on the File tab and then click on Options.

    An excel ‘Option’ dialog box is opened. 

    Step 2: Select Quick Access Toolbar from the list on the left pane

    Step 3: Click on the ‘Choose Command From’ field

    Step 4: Select Macros

    Step 5: Select the desired Macros. In our example this is Counting_negative_numbers

    Step 6: Click Add

    You will notice that the Macro name has been pushed to the right pane

    Step 7: Click OK 

    Quick Access Toolbar

    This closes the File Option Dialog box

    file option dialog

    Step 8: Your macro quick access appears on the top leftmost top of your MS Excel window

    Conclusion

    From this tutorial, we’ve gone over Counting Negative Numbers in Excel using several methods.

    You can also experiment counting the number of Positive values in a dataset.

    However, for every point where the “<0” condition was stated in the course of our tutorial, simply change it to “>0”.

    Share. Twitter LinkedIn Email Telegram
    Avatar photo
    Denise Elizabeth
    • Website
    • X (Twitter)
    • LinkedIn

    Denise is a Financial Controller with experience in Office Software (Excel & Word), Accounting, Bookkeeping, Business Incorporation/LLC, Taxes and IRS Issues and more. She Graduated from Portland State University in Business Management and went onto Seattle University to complete her Graduate (Masters) Degree in Organizational Systems Renewal. She contributes to Computing.net with her knowledge of Business Software, in particularly Microsoft Excel and Google Sheets.

    Related Posts

    How to Subtract in Google Sheets: Complete Guide

    July 31, 2024

    How to Convert Column List to Comma Separated List in Excel

    July 24, 2024

    How to Find the Last Monday of the Month in Excel

    July 24, 2024

    Convert Bytes to MB or GB in Excel: 3 Methods!

    July 24, 2024

    How to Remove Characters from Right in Excel

    July 30, 2023

    How to Create a Stem and Leaf Plot in Excel

    January 10, 2023
    Add A Comment

    Comments are closed.

    Latest

    Nvidia Stock Soars to New Record at $219.44 Ahead of May 20 Earnings

    May 12, 2026

    Rocket Lab Shares Surge Past $120 Following Wave of Analyst Upgrades

    May 12, 2026

    GM Shares Decline Following 600 IT Layoffs Amid Strategic AI Workforce Transformation

    May 12, 2026

    SES Delivers €847M Q1 Performance as Intelsat Integration and Aviation Deals Fuel Expansion

    May 12, 2026

    Trump Dismisses Iran Peace Proposal — Oil Markets React as Hormuz Remains Restricted

    May 12, 2026
    • Facebook
    • Twitter

    Latest Reviews

    Meta Platforms Shares Tumble 8% Despite Strong Q1 Performance Amid AI Investment Surge

    April 30, 2026

    Flush.com Review: Casino & Sportsbook With 275% Welcome Bonus

    March 7, 2026

    Katsubet Review: Crypto Casino With 300% Welcome Bonus & Free Spins

    March 7, 2026

    7Bit Review: Crypto Casino With 325% Bonus & 250 FS

    March 7, 2026

    Mega Dice Review: Crypto Casino With 200% Bonus & 50 Free Spins, Legit?

    March 7, 2026


    Home / Privacy Policy / Terms & Conditions

    Computing.net © 1996 - 2026 Kooc Media Ltd. All rights reserved. Registered Company No.05695741

    Type above and press Enter to search. Press Esc to cancel.