Home » excel » Excel extract and average values from column

# Excel extract and average values from column

Questions:

Is it possible if I have one column with names and another with pay. i.e.

```John     \$120
John     \$100
Sally    \$90
Sally    \$100
Sally    \$80```

to extract the values from column 2 for both John and Sally and then average them and place the results into two cells in another column? Could I use spreadsheet commands or do I need VBA to do this automatically.

You could use either

1. `AVERAGEIFS` (for xl07 and onwards)
2. A PivotTable see Debra’s site for a good reference

If your data was in `A2:B6` then this formula in `D1` (with “John” in `C1`) works
`=AVERAGEIFS(\$B\$2:\$B\$6,\$A\$2:\$A\$6,D1)` If you need your spreadsheet to work with excel versions earlier than 2007, you can also use this formula:

``````=SUM((\$D\$1=\$A\$2:\$A\$6)*(\$B\$2:\$B\$6)) / COUNTIF(\$A\$2,\$D\$1)
``````

This is an array formula, so you’ll need to press CTRL+SHIFT+ENTER instead of just ENTER when entering it.

The formula works with the sample table in brettdj‘s answer, where

• List of names is in A2:A6
• List of values is in B2:B6
• “John” is in D1
• This formula goes into E1 (or anywhere, actually).

It works by calculating the sum of values in B2:B6 where the corresponding A2:A6 value is John, and then dividing it by the total number of Johns in A2:A6, which returns the average.

``````=AVERAGEIFS(\$B\$2:\$B\$6,\$A\$2:\$A\$6,D1) - it doesn't work,