How to Calculate Module Averages with AVERAGEIF and Wildcards in Excel
Question details
The user needs to calculate average grades grouped by modules, where column headers use a module-chapter naming pattern (e.g., 1-1, 1-3).

- Product
- Spreadsheet
- Device & OS
- not provided
- Scenario
- A teacher or data analyst wants to average student grades dynamically based on specific module prefixes found in the column headers.
- Observed behavior
- Requires a formula that evaluates header strings to match a specific module number using wildcards, and then averages the corresponding values in a data row.
Ensure your dataset has distinct headers containing the module-chapter pattern (like '1-1' or '2-10') and that the grades within the rows are stored as numerical values, not text.
Use AVERAGEIF with a Wildcard Criterion
Concatenate the target module number with a wildcard (asterisk) to average all columns belonging to that specific module.
The AVERAGEIF function can match partial text strings by using wildcards. By referencing a cell that contains your target module number and joining it with an asterisk, the formula will locate all headers starting with that module number.
Type the module number you want to average into a reference cell, for example, J2.
Click on the cell where you want the calculated average to appear for the first student.
Type the formula =AVERAGEIF($C$2:$I$2, $J$2&"-*", C3:I3) and press Enter. This tells the system to look at the header row (C2:I2), find items starting with the J2 value plus a hyphen, and average the student's grades in row 3.
Drag the fill handle (the small square at the bottom right of the cell) downwards to calculate the average for the rest of the students.

Apply AVERAGEIF Across Multiple Modules and Students
Adjust absolute and relative cell references in the AVERAGEIF formula to seamlessly copy it across a large summary table.
Use WPS Spreadsheet to Effortlessly Calculate Conditional Averages
WPS Spreadsheet fully supports advanced functions like AVERAGEIF with wildcards, making it incredibly easy to group and calculate grades or process massive datasets quickly and accurately.
- 1. Open your dataset: Launch WPS Spreadsheet and open the document containing your student grades and module headers.
- 2. Select the destination cell: Click the cell where you want the calculated average to be displayed.
- 3. Input the formula: Type =AVERAGEIF(, select your header row range, add your wildcard parameter (e.g., J2&"-*"), select the row containing the student's grades, and press Enter.
- 4. Apply to all rows: Hover over the bottom-right corner of the active cell and drag the fill handle down to calculate the averages for your entire student roster instantly.

Frequently Asked Questions
Why is my AVERAGEIF formula returning a #DIV/0! error?
This error occurs if no cells meet the wildcard criteria, or if the cells that do meet the criteria are empty or contain non-numeric text. Double-check your header spelling and ensure the grades are formatted as numbers.
Can I use multiple criteria to calculate an average?
Yes. If you need to evaluate multiple conditions (such as specific module prefixes AND a grade greater than zero), you should use the AVERAGEIFS function, which allows for multiple criteria ranges and conditions.
Do wildcards work with pure numbers in AVERAGEIF?
Wildcards in AVERAGEIF function correctly only with text strings. If your headers are formatted strictly as numbers without any text elements (like hyphens), wildcard criteria will not evaluate them correctly. Ensure your labels contain text components or are formatted as text.




