Chapter 39: Wildcards in Excel Formulas

Introduction

Wildcards are special characters used in Excel formulas to represent unknown values or patterns. They are especially useful in functions like COUNTIF and SUMIF to perform calculations based on partial matches or specific text patterns. This chapter will cover how to use wildcards in Excel formulas to enhance your data analysis and management.


1. Types of Wildcards

  • Asterisk (*): Represents any number of characters. For example, *text* will match any text that contains “text” anywhere within it.
  • Question Mark (?): Represents a single character. For example, t?st will match “test” but not “toast”.
  • Tilde (~): Used to escape wildcards. For example, t~*st will match “t*st” literally.

2. Using Wildcards with COUNTIF

The COUNTIF function counts the number of cells that meet a specific condition.

  • Syntax: =COUNTIF(range, criteria)

Examples:

  1. Count Cells Containing Specific Text

Formula: =COUNTIF(A:A, “*text*”)

  1. Explanation: Counts the number of cells in column A that contain “text” anywhere within the cell.
  2. Count Cells Starting with Specific Text

Formula: =COUNTIF(A:A, “text*”)

  1. Explanation: Counts the number of cells in column A that start with “text”.
  2. Count Cells Ending with Specific Text

Formula: =COUNTIF(A:A, “*text”)

  1. Explanation: Counts the number of cells in column A that end with “text”.
  2. Count Cells with a Specific Number of Characters

Formula: =COUNTIF(A:A, “?????”)

  1. Explanation: Counts the number of cells in column A with exactly 5 characters.

3. Using Wildcards with SUMIF

The SUMIF function adds the values in a range that meet a specific condition.

  • Syntax: =SUMIF(range, criteria, [sum_range])

Examples:

  1. Sum Values Based on Specific Text

Formula: =SUMIF(A:A, “*text*”, B:B)

  1. Explanation: Sums the values in column B where the corresponding cells in column A contain “text”.
  2. Sum Values for Cells Starting with Specific Text

Formula: =SUMIF(A:A, “text*”, B:B)

  1. Explanation: Sums the values in column B where the corresponding cells in column A start with “text”.
  2. Sum Values for Cells Ending with Specific Text

Formula: =SUMIF(A:A, “*text”, B:B)

  1. Explanation: Sums the values in column B where the corresponding cells in column A end with “text”.

4. Using Wildcards with SUMIFS

The SUMIFS function adds the values in a range based on multiple criteria.

  • Syntax: =SUMIFS(sum_range, criteria_range1, criteria1, [criteria_range2, criteria2], …)

Examples:

  1. Sum Values with Multiple Conditions

Formula: =SUMIFS(B:B, A:A, “*text*”, C:C, “>10”)

  1. Explanation: Sums the values in column B where the corresponding cells in column A contain “text” and cells in column C are greater than 10.

5. Practice Assignment

  1. Count the Number of Cells Containing “Report”:
    • Use COUNTIF to count how many cells in column A contain the text “Report”.
  2. Sum the Values Where Cell Content Starts with “Data”:
    • Use SUMIF to sum the values in column B where the corresponding cells in column A start with “Data”.
  3. Count the Number of Cells Ending with “2024”:
    • Use COUNTIF to count how many cells in column A end with “2024”.
  4. Sum Values in Column B Where Column A Contains “Quarterly”:
    • Use SUMIF to sum the values in column B where the corresponding cells in column A contain “Quarterly”.
  5. Count Cells with Exactly 3 Characters in Column A:
    • Use COUNTIF to count the number of cells in column A with exactly 3 characters.

Pro Tip

  • Wildcards in Formulas: When using wildcards, remember that * can represent any sequence of characters, while ? represents a single character. Use these wildcards creatively to perform more flexible searches and calculations.

Leave a Reply

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