Fuction to return and evaluate fuction

M

Michael

I am looking for an easy way to set whole column of formuals to one
formula if cell a1 = "sum" and another formula if a1 = "count"

is there a way to use indirect to do something like this. I cant seem
to get it to work.

formulas in cells below would end up being either

=sum(b2:z2)
=sum(b3:z3)

and so on or

=count(b2:z2)
=count(b3:z3)

bascily I just want to swap out the function. the fuctions I am using
are both UDFs but each one only takes one reference


Any help would be apprecated.
 
X

Xt

I am looking for an easy way to set whole column of formuals to one
formula if cell a1 = "sum" and another formula if a1 = "count"

is there a way to use indirect to do something like this. I cant seem
to get it to work.

formulas in cells below would end up being either

=sum(b2:z2)
=sum(b3:z3)

and so on or

=count(b2:z2)
=count(b3:z3)

bascily I just want to swap out the function. the fuctions I am using
are both UDFs but each one only takes one reference

Any help would be apprecated.

You could just use an IF statement like =IF($a$1 =
"count",count(b2:z2),sum(b2:z2))

Or, as they are UDFs you could put them both into one UDF with another
argument telling which function to use. =UDF(f, other arguments) and
inside the UDF you have something like if if f="count" then... if
f="sum" then ... and so on. You could have as many functions as you
like. xt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top