View Single Post
  #3   Report Post  
Max
 
Posts: n/a
Default

One way is to use a pivot table (only a couple of clicks will get us there
!)

Assuming the posted data is in A1:B9, with headers "A", "B" in A1:B1

Select any cell within A1:B9

Click Data Pivot Table Report
Click Next Next

In Step 3 of the wizard:
Drag and drop "A" within the ROW area

Drag and drop "B" within the DATA area
(It'll appear as "Sum of B")

Double-click on "Sum of B" and in the dialog:
Select "Average" under "Summarize by"
Click "Number.." Number 2 d.p. (say) OK

Click OK at the main dialog
("Sum of B" will have changed to "Average of B")

Click Finish

The pivot table will be created in a new sheet to the left,
and yield the desired results:

Average of B
A Total
2 3.33
3 2.00
4 1.00
5 2.50
Grand Total 2.50
--
Rgds
Max
xl 97
---
Singapore, GMT+8
xdemechanik
http://savefile.com/projects/236895
--
"amerkarim" wrote in message
...

Hi Guys,

This is probably really easy but I have been struggling to average the
values in 2 linked collumns.

eg

A B
2 3
2 4
2 3
3 2
3 2
4 1
5 2
5 3

What I want to happen is it to calculate the average of the values in
the second column that match the same variable in the first column, and
paste them into a seperate row, so the formula would calculate
A B
2 (Average(3+4+3))
3 (Average(2+2))
4 1
5 (Average(2+3))

to produce these columns

A B
2 3.33
3 2
4 1
5 2.5

I have been trying to write a macro but with no luck.

Please help.

Many thanks in advance for looking.

Amer Karim


--
amerkarim