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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -