i have data shown: http://bit.ly/1o6aawx
for each department have calculate minimum, maximum wait time , if possible, average time too. no. of departments can dynamic. have got no clue how this.
using following example:
you need use sumif() total in column e
http://www.techonthenet.com/excel/formulas/sumif.php
in case need following (row 2):
=sumif($b$2:$b$11,"=" & d2,$c$2:$c$11) then countif in column f (row 2):
https://support.office.com/en-za/article/countif-function-e0de10c6-f885-4e71-abb4-1f464816df34
=countif(b2:b11,"="&d2) average sum/count!
and can use following information work out max , min ... http://www.contextures.com/excelminmaxfunction.html#minif
by placing department name in column d, , referencing in sumif\countif forumals, can create list of departments long want!
note minif example array formula ... best first if you've never used 1 before ... http://www.excel-easy.com/functions/array-formulas.html
if must use vba, work example worksheet i've shown @ top of post ...
sub calculatestuff() dim ddepartmenttotals(4) integer dim ddepartmentminimum(4) integer: = 1 4: ddepartmentminimum(i) = 32767: next dim ddepartmentmaximum(4) integer dim ddepartmentaverage(4) integer dim ddepartmentcount(4) integer = 2 11 ideptno = cint(right(sheets("sheet1").cells(i, 2), 1)) ddepartmenttotals(ideptno) = ddepartmenttotals(ideptno) + sheets("sheet1").cells(i, 3) if ddepartmentmaximum(ideptno) < sheets("sheet1").cells(i, 3) ddepartmentmaximum(ideptno) = sheets("sheet1").cells(i, 3) if sheets("sheet1").cells(i, 3) < ddepartmentminimum(ideptno) ddepartmentminimum(ideptno) = sheets("sheet1").cells(i, 3) ddepartmentcount(ideptno) = ddepartmentcount(ideptno) + 1 next = 1 4 ddepartmentaverage(i) = ddepartmenttotals(i) \ ddepartmentcount(i) next end sub 
Comments
Post a Comment