This post will introduce you to three methods for** calculating the average of a range of numbers in Microsoft Excel, excluding the smallest and largest values**. The first and second method involves using the formula, while the third method utilizes VBA code.

Table of Contents

- 1. Calculate the Average Excluding the Smallest and Highest Numbers Using Formula
- 2. Calculate the Average Excluding the Smallest and Highest Numbers Using TRIMMEAN Function
- 3. Calculate the Average Excluding the Smallest and Highest Numbers with VBA Code
- 4. Video: Calculate the Average Excluding the Smallest and Highest Numbers
- 5. Conclusion
- 6. Related Functions

## 1. Calculate the Average Excluding the Smallest and Highest Numbers Using Formula

Calculating the average for a batch of data is frequently used in our daily life. But for some cases like statistic the average score in a competition, or price analysis, we often calculate the average excluding the smallest and highest numbers in the range of data.

As we know we can use some formula like **MAX **or **MIN **to get the maximum value or minimum value in a range, so we can use formula combination to calculate the average excluding the MAX and MIN values. In this article, we will provide you some useful formulas to solve our problem.

We can use the total amount minus the smallest value and the highest value, then divide the total number-2, so for this case we can use the similar formula combination to calculate the average. Details see steps below.

**Step1:** In any blank cell, enter the following formula.

` =(SUM(A2:A9)-MIN(A2:A9)-MAX(A2:A9))/(COUNT(A2:A9)-2)`

**Step 2:** Click **Enter** to get the result. Verify that average is calculated properly.

## 2. Calculate the Average Excluding the Smallest and Highest Numbers Using TRIMMEAN Function

Above formula combination is a little complex, we can use a special function **TRIMMEAN **to calculate the average for some conditions.

**Step 1:** In any blank cell, enter the formula

`=TRIMMEAN(A2:A9,2/COUNT(A2:A9))`

**Step 2:** Click **Enter** to get the result. Verify that average is calculated properly. It is the same with the value calculated by the formula combination.

## 3. Calculate the Average Excluding the Smallest and Highest Numbers with VBA Code

If we frequently use the function to calculate the average in daily work, we can create a **user defined function **by VBA, then we can use the function directly.

**Step1: **Click **Developer tab->Visual Basic** or **Alt+F11** to load **Microsoft Visual Basic for Applications** window.

**Step2: **Click **Insert->Module** to insert a module. Then Module1 is created.

**Step3:** Enter below code in **Module** window.

```
Function AverageExcludeMaxAndMin_excelhow(myrange) As Variant
With Application
AverageExcludeMaxAndMin_excelhow = (.Sum(myrange) - .Max(myrange) - .Min(myrange)) / (.Count(myrange) - 2)
End With
End Function
```

In above code, we create the function as **AverageExcludeMaxAndMin_excelhow**. You can shorten the function name per your requirement.

**Step4:** In any blank cell, enter **=Average**, verify that user defined function **AverageExcludeMaxAndMin_excelhow** is loaded.

**Step5:** In any blank cell, enter the formula:

` =AverageExcludeMaxAndMin_excelhow(A2:A9)`

**Step6:** Click **Enter** to get the result.

So after above steps, we can directly use this function to calculate the average in following work directly.

## 4. Video: Calculate the Average Excluding the Smallest and Highest Numbers

This video will demonstrate how to use a User Defined Function (UDF) and formula to calculate the average of a range of numbers in Excel, excluding the smallest and largest values.

## 5. Conclusion

These methods are useful when you want to calculate the average of a range of values but want to exclude any outliers that could skew the result. By following the steps outlined in this post, you can easily calculate the average of a range of values in Excel while excluding the smallest and largest numbers.

## 6. Related Functions

- Excel SUM function

The Excel SUM function will adds all numbers in a range of cells and returns the sum of these values. You can add individual values, cell references or ranges in excel.The syntax of the SUM function is as below:= SUM(number1,[number2],…)… - Excel MIN function

The Excel MIN function returns the smallest numeric value from the numbers that you provided. Or returns the smallest value in the array.The MIN function is a build-in function in Microsoft Excel and it is categorized as a Statistical Function.The syntax of the MIN function is as below:= MIN(num1,[num2,…numn])…. - Excel MAX function

The Excel MAX function returns the largest numeric value from the numbers that you provided. Or returns the largest value in the array.= MAX(num1,[num2,…numn])… - Excel COUNT function

The Excel COUNT function counts the number of cells that contain numbers, and counts numbers within the list of arguments. It returns a numeric value that indicate the number of cells that contain numbers in a range…