Skip to content
Free Excel Tutorials
  • Home
  • Excel For Beginners
  • Excel Intermediate
  • Advanced Excel For Experts

Data Analysis

  • How to Create One and Two Variable Data Tables in Excel
  • How to add Trendline to a chart in Excel
  • How to Sort by Color in Excel
  • Add Outline to Data in Excel
  • How To Compare Two Lists in Excel

References

  • VLOOKUP function: Description, Usage, Syntax, Examples and Explanation
  • INDEX function: Description, Usage, Syntax, Examples and Explanation
  • How to use Excel TRANSPOSE Function
  • Convert text string to valid reference in Excel using Indirect function
  • Lookup entire row in Excel

Data Validations

  • Excel Data validation date in next 30 days
  • Excel Data validation whole percentage only
  • Excel Data validation no punctuation
  • Excel Data validation allow uppercase only
  • Excel Data validation must contain specific text

Example of COUNTIFS with variable table column in Excel

by

To use COUNTIFS with a variable table column, you can use INDEX and MATCH to find and retrieve the column for COUNTIFS. See example below:

Formula

=COUNTIFS(INDEX(Table,0,MATCH(name,Table[#Headers],0)),criteria))

Example of COUNTIFS with variable table column in Excel

Explanation

In the example shown, the formula in H5 is:

=COUNTIFS(INDEX(Table1,0,MATCH(G5,Table1[#Headers],0)),"x")

How this formula works

First, for context, it’s important to note that you can use COUNTIFS with a regular structured reference like this:

=COUNTIFS(Table1[Swim],"x")

This is a much simpler formula, but you can’t copy it down column H, because the column reference won’t change.

The example on this page therefore is meant to show one way to set up a formula that references a table with a variable column reference.

Working from the inside out, the MATCH function is used to find the position of the column name listed in column G:

MATCH(G5,Table1[#Headers],0)

MATCH uses the value in G5 as lookup value, the headers in Table1 for array, and 0 for match type to force an exact match. The result for G5 is 2, which goes into INDEX as the column number:

INDEX(Table1,0,2,0))

Notice row number has been set to zero, which causes INDEX to return the entire column, which is C5:C13 in this example.

This reference goes into COUNTIFS normally:

=COUNTIFS(C5:C13,"x")

COUNTIFS counts cells that contain “x”, and returns the result, 5 in this case.

When the formula is copied down column H, INDEX and MATCH return the correct column reference to COUNTIFS at each row.

Alternative with INDIRECT

The INDIRECT function can also be used to set up a variable column reference like this:

=COUNTIFS(INDIRECT("Table1["&G5&"]"),"x")

Note: INDIRECT is a volatile function and can cause performance problems in larger or more complicated workbooks.

Here, the structured reference is assembled as text, and INDIRECT evaluates the text as a proper cell reference.

Post navigation

Previous Post:

How to calculate project complete percentage in Excel

Next Post:

Popularly Used Excel Functions and their examples

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

Logical Functions

  • AND function: Description, Usage, Syntax, Examples and Explanation
  • Return blank if in Excel
  • How to use IFS function in Excel
  • Not Equal To ‘<>‘ operator in Excel
  • IF with boolean logic in Excel

Date Time

  • How to calculate next anniversary date or birthday in Excel
  • Count day of week between dates in Excel
  • Generate series of dates by weekends in Excel
  • Get days, hours, and minutes between dates in Excel
  • Convert text timestamp into time in Excel

Grouping

  • Group numbers at uneven intervals in Excel
  • Group times into unequal buckets in Excel
  • If cell contains one of many things in Excel
  • Group times into 3 hour buckets in Excel
  • How to randomly assign people to groups in Excel

General

  • How to generate random number between two numbers in Excel
  • 231 Keyboard Shortcut Keys In Excel
  • Basic text sort formula in Excel
  • Transpose: Switch ‘Rows to Columns’ or ‘Columns to Rows’ in Excel
  • Basic error trapping example in Excel
© 2026 xlsoffice . All Right Reserved. | Teal Smiles | Abbreviations And Their Meaning