Count number within slabs through excels function / formula -


i want count amount between different value slabs. example

**customer      amount**                100 b               300               500 c               700 d               900 e               1100 f               1300 g               1500 h               1700               1900 

desired result

**solutions          count** between 100-500         2 between 500-1000        3 between 1000-1500       3 between 1500-2000       2 

i tried trough countif formula include lot of efforts when there huge data , lots of amount slabs included

if can help, have peace of code generates formula "slabs", , calculate number of occurrences within.

say have values in column c (beware c contain numbers; sure can make $c$1:$c$1000$or so), , plots of slabs start 0 in $d$14. output in column g (and debug in columns e - f)

with function maker1c1:

function maker1c1(a1formula string) string  maker1c1 = application.convertformula( _     formula:=a1formula, _     fromreferencestyle:=xla1, _     toreferencestyle:=xlr1c1, _     toabsolute:=xlabsolute)  end function 

then can work below (i made 10 slabs):

public sub it()     on error goto errortrap     dim wkrange range     dim inputrange string     dim argformula string     this_workbook = "mywbook.xlsm"     mysheet = "mysheet"     ' important: make work necessary use wb+sheet reference     inputrange = "[" & this_workbook & "]" & mysheet & "!$c:$c"     inputrange = maker1c1(inputrange)      set wkrange = thisworkbook.sheets(mysheet).range("d15:d25")     ' d14: starting plot     each c in wkrange         upbound = c.value         lowbound = c.offset(-1, 0).value         argformula = "count(" & inputrange & ") " & _                  " - countif(" & inputrange & " ,"">" & upbound & """) " & _                  " - countif(" & inputrange & " ,""<=" & lowbound & """)"         c.offset(0, 1).value = argformula         c.offset(0, 2).value = "between " & lowbound & " , " & upbound         c.offset(0, 3).formular1c1 = "=" & argformula     next  exit sub errortrap:     beep     msgbox "failed" & chr(13) & _                     "arg: " & argformula & chr(13) & _                     "error number: " & err & chr(13) & _                     error(err) end sub 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -