Skip to content
xlsoffice. All Rights Reserved
  • Home
  • Excel For Beginners
  • Excel Intermediate
  • Advanced Excel For Experts

Lookup and Reference Examples

  • How to use Excel TRANSPOSE Function
  • Create hyperlink with VLOOKUP in Excel
  • Left Lookup in Excel
  • How to reference named range different sheet in Excel
  • Convert text string to valid reference in Excel using Indirect function

Data Analysis Examples

  • How to Create Gantt Chart in Excel
  • Reverse List in Excel
  • How To Perform and Interpret Regression Analysis in Excel
  • How To Sort One Column or Multiple Columns in Excel
  • How To Insert and Customize Sparklines in Excel

Data Validation Examples

  • Excel Data validation allow weekday only
  • Excel Data validation specific characters only
  • Excel Data validation whole percentage only
  • Excel Data validation date in next 30 days
  • Excel Data validation unique values only

COUNTIF with non-contiguous range in Excel

by

This tutorial shows how to COUNTIF with non-contiguous range in Excel using the example below;

Formula

=SUM(COUNTIF(INDIRECT({"range1","range2","range3"}),criteria))

Explanation

To use count a non-contiguous range with criteria, you can use the COUNTIF function together with INDIRECT and SUM. In the example shown, cell I5 contains this formula:

=SUM(COUNTIF(INDIRECT({"B5:B8","D7:D10","F6:F11"}),">50"))

How this formula works

COUNTIF counts the number of cells in a range that meet given criteria. If you try to use COUNTIF with multiple ranges separated by commas, you’ll get an error. One solution is to write out the ranges as text in an array constant inside the INDIRECT function like this:

INDIRECT({"B5:B8","D7:D10","F6:F11"})

INDIRECT will evaluate the text values and pass the multiple ranges into COUNTIF. Because COUNTIF receives more than one range, it will return more than one result in an array. We use the SUM function to “catch” and handle the array:

=SUM({4,2,3})

The SUM function then returns the sum of all values, 9. Although this is an array formula, it does not require CSE, since we are using an array constant.

Worked Example:   How to translate letters to numbers in Excel

Note: INDIRECT is a volatile function and can impact workbook performance.

Worked Example:   Highlight duplicate values in Excel

Multiple COUNTIFs

Another way to solve this problem is to use more than one COUNTIF:

=COUNTIF(B5:B8,">50")+COUNTIF(D7:D10,">50")+COUNTIF(F6:F11,">50")

With a limited number of ranges, this approach may be easier to implement. It avoids possible performance impacts of INDIRECT, and allows a normal formula syntax for ranges, so ranges will update automatically with worksheet changes.

Worked Example:   Count cells that contain negative numbers

Single cell ranges

With single cell ranges, you can write a formula without COUNTIF like this:

=(A1>50)+(C1>50)+(E1>50)

Each expression returns TRUE or FALSE, when are coerced to 1 and zero during the math operation. This is an example of using boolean logic in a formula.

Post navigation

Previous Post:

COUNTIFS with multiple criteria and OR logic in Excel

Next Post:

Count visible rows only with criteria in Excel

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Learn Basic Excel

Ribbon
Workbook
Worksheets
Format Cells
Find & Select
Sort & Filter
Templates
Print
Share
Protect
Keyboard Shortcuts

Categories

  • Charts
  • Data Analysis
  • Data Validation
  • Excel Functions
    • Cube Functions
    • Database Functions
    • Date and Time Functions
    • Engineering Functions
    • Financial Functions
    • Information Functions
    • Logical Functions
    • Lookup and Reference Functions
    • Math and Trig Functions
    • Statistical Functions
    • Text Functions
    • Web Functions
  • Excel VBA
  • Excel Video Tutorials
  • Formatting
  • Grouping
  • Others
  • Add line break based on OS in Excel
  • How to extract multiple lines from a cell in Excel
  • Normalize text by removing punctuations, extra spaces and more in Excel
  • How to strip protocol and trailing slash from URL in Excel
  • Replace one character with another in Excel
  • Convert decimal hours to Excel time
  • Convert date to Julian format in Excel
  • How to get Weekdays, Working days between Two Dates in Excel
  • Convert date to month and year in Excel
  • Sum through n months in Excel
  • DURATION function: Description, Usage, Syntax, Examples and Explanation
  • FVSCHEDULE function: Description, Usage, Syntax, Examples and Explanation
  • COUPPCD function: Description, Usage, Syntax, Examples and Explanation
  • Calculate periods for annuity in Excel
  • How to Calculate Tax Rates in Excel
© 2022 xlsoffice . All Right Reserved. | Teal Smiles