DavidJRuess
New Member
- Joined
- Feb 22, 2012
- Messages
- 6
Hi Everyone,
I'm trying to come up with a simple macro that will scan through a list and calculate the average for a range that has a specific variable.
So it would go through the following table and give me the average for all the red's and then the average for the blue, and then the green, etc... (see table below).
Nothing is fixed. So I might have seventy five different Red numbers today and 45 red numbers tomorrow, sometimes there won't be any red numbers. And the numbers in column B will change each day as well.
I'm hoping to paste these results further down the sheet, or on another sheet (doesn't matter), where it lists the column A variable with the average next to it:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Red
[/TD]
[TD]60
[/TD]
[/TR]
[TR]
[TD]Blue
[/TD]
[TD]77
[/TD]
[/TR]
[TR]
[TD]etc...
[/TD]
[TD]etc..
[/TD]
[/TR]
</tbody>[/TABLE]
Any help would be appreciative. I started trying to use a For, first row to last row, type of formula and using an if, to calculate for when the variable was only Red.
But then I started researching and figured there was a much simpler way to do it using Averageif, or an evaluate, or find method.
Thank you for your help
David
[TABLE="width: 500"]
<tbody>[TR]
[TD]Column A
[/TD]
[TD]Column B
[/TD]
[/TR]
[TR]
[TD]Red
[/TD]
[TD]15
[/TD]
[/TR]
[TR]
[TD]Red
[/TD]
[TD]37
[/TD]
[/TR]
[TR]
[TD]Red
[/TD]
[TD]132
[/TD]
[/TR]
[TR]
[TD]Red
[/TD]
[TD]56
[/TD]
[/TR]
[TR]
[TD]Blue
[/TD]
[TD]98
[/TD]
[/TR]
[TR]
[TD]Blue
[/TD]
[TD]56
[/TD]
[/TR]
[TR]
[TD]Green
[/TD]
[TD]24
[/TD]
[/TR]
[TR]
[TD]Green
[/TD]
[TD]25
[/TD]
[/TR]
[TR]
[TD]Green
[/TD]
[TD]100
[/TD]
[/TR]
[TR]
[TD]Black
[/TD]
[TD]24
[/TD]
[/TR]
[TR]
[TD]Black
[/TD]
[TD]34
[/TD]
[/TR]
[TR]
[TD]Black
[/TD]
[TD]52
[/TD]
[/TR]
[TR]
[TD]Black
[/TD]
[TD]78
[/TD]
[/TR]
[TR]
[TD]Black
[/TD]
[TD]98
[/TD]
[/TR]
[TR]
[TD]Yellow
[/TD]
[TD]67
[/TD]
[/TR]
</tbody>[/TABLE]
I'm trying to come up with a simple macro that will scan through a list and calculate the average for a range that has a specific variable.
So it would go through the following table and give me the average for all the red's and then the average for the blue, and then the green, etc... (see table below).
Nothing is fixed. So I might have seventy five different Red numbers today and 45 red numbers tomorrow, sometimes there won't be any red numbers. And the numbers in column B will change each day as well.
I'm hoping to paste these results further down the sheet, or on another sheet (doesn't matter), where it lists the column A variable with the average next to it:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Red
[/TD]
[TD]60
[/TD]
[/TR]
[TR]
[TD]Blue
[/TD]
[TD]77
[/TD]
[/TR]
[TR]
[TD]etc...
[/TD]
[TD]etc..
[/TD]
[/TR]
</tbody>[/TABLE]
Any help would be appreciative. I started trying to use a For, first row to last row, type of formula and using an if, to calculate for when the variable was only Red.
But then I started researching and figured there was a much simpler way to do it using Averageif, or an evaluate, or find method.
Thank you for your help
David
[TABLE="width: 500"]
<tbody>[TR]
[TD]Column A
[/TD]
[TD]Column B
[/TD]
[/TR]
[TR]
[TD]Red
[/TD]
[TD]15
[/TD]
[/TR]
[TR]
[TD]Red
[/TD]
[TD]37
[/TD]
[/TR]
[TR]
[TD]Red
[/TD]
[TD]132
[/TD]
[/TR]
[TR]
[TD]Red
[/TD]
[TD]56
[/TD]
[/TR]
[TR]
[TD]Blue
[/TD]
[TD]98
[/TD]
[/TR]
[TR]
[TD]Blue
[/TD]
[TD]56
[/TD]
[/TR]
[TR]
[TD]Green
[/TD]
[TD]24
[/TD]
[/TR]
[TR]
[TD]Green
[/TD]
[TD]25
[/TD]
[/TR]
[TR]
[TD]Green
[/TD]
[TD]100
[/TD]
[/TR]
[TR]
[TD]Black
[/TD]
[TD]24
[/TD]
[/TR]
[TR]
[TD]Black
[/TD]
[TD]34
[/TD]
[/TR]
[TR]
[TD]Black
[/TD]
[TD]52
[/TD]
[/TR]
[TR]
[TD]Black
[/TD]
[TD]78
[/TD]
[/TR]
[TR]
[TD]Black
[/TD]
[TD]98
[/TD]
[/TR]
[TR]
[TD]Yellow
[/TD]
[TD]67
[/TD]
[/TR]
</tbody>[/TABLE]