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 LOOKUP Function
  • Two-column Lookup in Excel
  • Complete List of Excel Lookup and Reference Functions, References and Examples
  • How to get address of named range in Excel
  • Offset in Excel

Data Analysis Examples

  • How to Use Solver Tool in Excel
  • Filter Data Based on Date in Excel
  • How To Create Pareto Chart in Excel
  • Excel Pie Chart
  • How To Filter Data in Excel

Data Validation Examples

  • Excel Data validation don’t exceed total
  • Excel Data validation allow weekday only
  • Excel Data validation only dates between
  • Prevent invalid data entering in specific cells
  • Excel Data validation specific characters only

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))

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.

Worked Example:   How to reference named range different sheet in Excel

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.

Worked Example:   3D SUMIF for multiple worksheets in Excel

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.

Worked Example:   Dynamic lookup table with INDIRECT in Excel

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 create running total in an Excel Table

Next Post:

Calculate Conditional Percentile ‘IF’ in table 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
  • How to find and replace multiple values at same time in Excel
  • Extract middle name from full name — Manipulating NAMES in Excel
  • CLEAN function: Description, Usage, Syntax, Examples and Explanation
  • Put names into proper case — Manipulating NAMES in Excel
  • How to extract word containing specific text in Excel
  • Get first day of month in Excel
  • How to determine year is a leap year in Excel
  • NOW function: Description, Usage, Syntax, Examples and Explanation
  • How to calculate percent of year complete in Excel
  • How to calculate nth day of week in month in Excel
  • Bond valuation example in Excel
  • Calculate payment for a loan in Excel
  • Calculate interest rate for loan in Excel
  • COUPDAYS function: Description, Usage, Syntax, Examples and Explanation
  • PMT, RATE, NPER, PV and FV Financial Functions in Excel
Acronyms, Abbreviations, Initialism & What They Stand For
© 2021 xlsoffice. All Rights Reserved | Teal Smiles