Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 51
Default How to write this function?

Say I have the following

A B
1 2 10
2 4 5
3 2 20
4 2 30
5 4 11

How can I write a func. so if the cell values are equal,
for A col, it will add the values in corresponding B col,
then average the value out?

avg = SUM / #occur

So in may example, A1,A3 and A5 are all 2's so...
avg = 60 / 3 = 20

Again, A2 and A5 are both 4's so...
avg = 16 / 2 = 8

Thanks!

--
- Zilla
(Remove XSPAM)


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max Max is offline
external usenet poster
 
Posts: 9,221
Default How to write this function?

One way ..
In C1: =SUMIF(A:A,A1,B:B)/COUNTIF(A:A,A1)
Copy down
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Zilla" wrote in message
...
Say I have the following

A B
1 2 10
2 4 5
3 2 20
4 2 30
5 4 11

How can I write a func. so if the cell values are equal,
for A col, it will add the values in corresponding B col,
then average the value out?

avg = SUM / #occur

So in may example, A1,A3 and A5 are all 2's so...
avg = 60 / 3 = 20

Again, A2 and A5 are both 4's so...
avg = 16 / 2 = 8

Thanks!

--
- Zilla
(Remove XSPAM)




  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,339
Default How to write this function?

=AVERAGE(IF($A$1:$A$100=2,$B$1:$B$100))

entered with Ctrl+Shift+Enter

"Max" wrote:

One way ..
In C1: =SUMIF(A:A,A1,B:B)/COUNTIF(A:A,A1)
Copy down
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Zilla" wrote in message
...
Say I have the following

A B
1 2 10
2 4 5
3 2 20
4 2 30
5 4 11

How can I write a func. so if the cell values are equal,
for A col, it will add the values in corresponding B col,
then average the value out?

avg = SUM / #occur

So in may example, A1,A3 and A5 are all 2's so...
avg = 60 / 3 = 20

Again, A2 and A5 are both 4's so...
avg = 16 / 2 = 8

Thanks!

--
- Zilla
(Remove XSPAM)





  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 51
Default How to write this function?

Ok thanks, I'll try this way...

"Max" wrote in message
...
One way ..
In C1: =SUMIF(A:A,A1,B:B)/COUNTIF(A:A,A1)
Copy down
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Zilla" wrote in message
...
Say I have the following

A B
1 2 10
2 4 5
3 2 20
4 2 30
5 4 11

How can I write a func. so if the cell values are equal,
for A col, it will add the values in corresponding B col,
then average the value out?

avg = SUM / #occur

So in may example, A1,A3 and A5 are all 2's so...
avg = 60 / 3 = 20

Again, A2 and A5 are both 4's so...
avg = 16 / 2 = 8

Thanks!

--
- Zilla
(Remove XSPAM)






  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 51
Default How to write this function?

Thanks but this will be tedious since you hard-coded "2",
which is just an example value. So if I change "2" to "19",
I'd have to change it in ALL the formulas...

"Toppers" wrote in message
...
=AVERAGE(IF($A$1:$A$100=2,$B$1:$B$100))

entered with Ctrl+Shift+Enter

"Max" wrote:

One way ..
In C1: =SUMIF(A:A,A1,B:B)/COUNTIF(A:A,A1)
Copy down
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Zilla" wrote in message
...
Say I have the following

A B
1 2 10
2 4 5
3 2 20
4 2 30
5 4 11

How can I write a func. so if the cell values are equal,
for A col, it will add the values in corresponding B col,
then average the value out?

avg = SUM / #occur

So in may example, A1,A3 and A5 are all 2's so...
avg = 60 / 3 = 20

Again, A2 and A5 are both 4's so...
avg = 16 / 2 = 8

Thanks!

--
- Zilla
(Remove XSPAM)









  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,339
Default How to write this function?

Change the 2 to a cell address

=AVERAGE(IF($A$1:$A$100=$Z$1,$B$1:$B$100))


"Zilla" wrote:

Ok thanks, I'll try this way...

"Max" wrote in message
...
One way ..
In C1: =SUMIF(A:A,A1,B:B)/COUNTIF(A:A,A1)
Copy down
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Zilla" wrote in message
...
Say I have the following

A B
1 2 10
2 4 5
3 2 20
4 2 30
5 4 11

How can I write a func. so if the cell values are equal,
for A col, it will add the values in corresponding B col,
then average the value out?

avg = SUM / #occur

So in may example, A1,A3 and A5 are all 2's so...
avg = 60 / 3 = 20

Again, A2 and A5 are both 4's so...
avg = 16 / 2 = 8

Thanks!

--
- Zilla
(Remove XSPAM)







  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max Max is offline
external usenet poster
 
Posts: 9,221
Default How to write this function?

welcome. it should return what you're after.
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Zilla" wrote in message
...
Ok thanks, I'll try this way...



  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max Max is offline
external usenet poster
 
Posts: 9,221
Default How to write this function?

You could point Topper's array suggestion to the source cells in col A
Eg in C1, array-entered (press CTRL+SHIFT+ENTER):
=AVERAGE(IF($A$1:$A$100=A1,$B$1:$B$100))
Copy down (Adapt the ranges to suit before you copy down)
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Zilla" wrote in message
...
Thanks but this will be tedious since you hard-coded "2",
which is just an example value. So if I change "2" to "19",
I'd have to change it in ALL the formulas...

"Toppers" wrote in message
...
=AVERAGE(IF($A$1:$A$100=2,$B$1:$B$100))

entered with Ctrl+Shift+Enter



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can you write your own NETWORKDAYS function? Duncs Excel Worksheet Functions 12 November 7th 06 01:04 PM
Help me write a function please? justo316 Excel Worksheet Functions 10 January 12th 06 06:10 PM
help me write function? Zach Excel Worksheet Functions 5 August 3rd 05 03:12 PM
is there a way to write this function? Steve Excel Worksheet Functions 6 March 16th 05 02:48 PM
how do I write a vlookup function within an iserror function so t. JBLeeds Excel Worksheet Functions 2 March 16th 05 10:30 AM


All times are GMT +1. The time now is 12:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"