ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to calculate Min,Median,Max values in non consecutive rows via (https://www.excelbanter.com/excel-programming/426651-how-calculate-min-median-max-values-non-consecutive-rows-via.html)

Pete

How to calculate Min,Median,Max values in non consecutive rows via
 
Hi,

I would like to calculate the Min, Median and Max values in non consecutive
rows via VBA.

Year Value
2007 10
2007 20
2008 11
2009 12
2007 30
2008 25
2009 55
2008 26
2008 16
2009 40

I would like to represent the results as follows:

2007 Min = xxx
Median = xxx
Max = xxx

2008 Min = xxx
Median = xxx
Max = xxx

2009 Min = xxx
Median = xxx
Max = xxx

Any idea what my code would look like?

Pete.

Gary''s Student

How to calculate Min,Median,Max values in non consecutive rows via
 
You can calculate your statistics (even non-consecutive) without any VBA:

=MAX(IF(A1:A10=2007,B1:B10,""))
=MIN(IF(A1:A10=2007,B1:B10,""))
=MEDIAN(IF(A1:A10=2007,B1:B10,""))

and will display:

30
10
20


These are array formulae. They must be entered with CNTRL-SHFT-ENTER rather
than just the ENTER key.

If you must use VBA, then use it to insert the equations!
--
Gary''s Student - gsnu200844


"Pete" wrote:

Hi,

I would like to calculate the Min, Median and Max values in non consecutive
rows via VBA.

Year Value
2007 10
2007 20
2008 11
2009 12
2007 30
2008 25
2009 55
2008 26
2008 16
2009 40

I would like to represent the results as follows:

2007 Min = xxx
Median = xxx
Max = xxx

2008 Min = xxx
Median = xxx
Max = xxx

2009 Min = xxx
Median = xxx
Max = xxx

Any idea what my code would look like?

Pete.



All times are GMT +1. The time now is 02:44 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com