excel - Function to sum of a range of cells meeting a condition while skipping hidden rows? -


is there excel function calculate sum of range of cells containing hidden rows (filtered user using auto filter) , meet condition?

for example, consider following sheet:

   |           | b      | 1 | numbers     | country| 2 | 1           | x      | 3 | 2           | x      |  4 | 3           | y      | 5 | 4           | x      |  

applying auto filter showing country x, results in following, row 4 gets hidden:

   |           | b      | 1 | numbers     | country| 2 | 1           | x      | 3 | 2           | x      |  5 | 4           | x      |  

i calculate sum of numbers in column greater 1 while taking autofilter user account.

i've tried following solution combining subtotal array filter:

=subtotal(9;(a2:a5>=2)*(a2:a5))  

this not work due mismatch of argument types. not know how can convert array reference.

based on mehow answer created function, evaluates condition before calculating sum.

function sumvisiblewithcondition(myrange range, condition string) integer     dim sum long     dim c range     each c in myrange         if not c.entirerow.hidden             if evaluate("" & c.value & condition)                 sum = sum + c.value             end if         end if     next c     sumvisiblewithcondition = sum   end function 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -