excel vba - VBA - invalid qualifier when getting array length -
i trying create function puts param array, returns random index value of array. code gets compile error: invalid qualifier
@ arr.length
. far have:
function myfunction(list range) dim arr() dim indx arr = list indx = (int(rnd()) * arr.length) 'error here myfunction = indx end function
not sure if using array right, or returning value right - please help
revision 1
replaced .length ubound , lbound - getting #value
error in cell when should returning array's index value.
function myfunction(list range) dim arr() dim indx integer arr = list indx = int(rnd() * (ubound(arr) - lbound(arr) + 1)) 'indx myfunction = arr(indx) end function
when assign value of range array, 2-d array dimensions (1 numberofrows, 1 numberofcols)
, solution alter arr(indx)
function myfunction(list range) dim arr() dim indx integer arr = list indx = int(rnd() * (ubound(arr) - lbound(arr) + 1)) 'indx myfunction = arr(indx,1) end function
vba excel-vba
No comments:
Post a Comment