VBA function with array inputs -


i trying create more user friendly version of function sumproduct don't understand why function returning #value!. please advise:

below code both array inputs of same length:

function sp(x variant, y variant) double  psum = 0   = lbound(x) ubound(x)     qsum = x(i) * y(i)     psum = psum + qsum next  sp = psum  end function 

you need state qsum , psum are. make sure arrays being called in of same type variant.:

function sp(x variant, y variant) double dim psum, qsum double psum = 0   = lbound(x) ubound(x)     qsum = x(i) * y(i)     psum = psum + qsum next  sp = psum  end function 

test sub

  sub test()     dim ex, wy variant     ex = array(1, 2, 3, 4, 5)     wy = array(2, 3, 4, 5, 6)     call sp(ex, wy)      end sub 

this worked me without value error


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -