in excel vba, know can use array formula on multiple cells, selecting range of cells of col c, , doing =a1:10*b1:b10 ctrl-shift-enter.
but suppose instead of multiplication operator, want mymult.
how write mymult function?
function mymult(a integer, b integer) mymult = * b end function
what have isn't working
declare arguments variant. use application.caller.hasarray
check if udf used array formula:
public function mymult(a, b) if application.caller.hasarray dim valsa(), valsb(), r& valsa = a.value valsb = b.value r = lbound(valsa) ubound(valsa) valsb(r, 1) = valsa(r, 1) * valsb(r, 1) next mymult = valsb else mymult = * b end if end function
note need select c1:c3 before pressing ctrl + shift + enter.
Comments
Post a Comment