Excel VBA loop and get value from an array -


i have following code retrieve selection making array of string.

dim strargument variant dim irange range dim ricosstring variant  set irange = selection ricosstring = rangetostringarray(irange)  dim varray variant = lbound(ricosstring) ubound(ricosstring)     set varray = ricosstring(i) 

my problem here on ricosstring(i). throwing error subscript out of range. ideas why?

here code rangetostringarray

public function rangetostringarray(therange excel.range) string()  dim variantvalues variant variantvalues = therange.value  dim stringvalues() string redim stringvalues(1 ubound(variantvalues, 1), 1 ubound(variantvalues, 2))  dim columncounter long, rowcounter long rowcounter = ubound(variantvalues, 1) 1 step -1    columncounter = ubound(variantvalues, 2) 1 step -1        stringvalues(rowcounter, columncounter) = cstr(variantvalues(rowcounter, columncounter))    next columncounter next rowcounter  rangetostringarray = stringvalues 

end function

rangetostringarray 2 dimensional reference 1 dimensional set varray = ricosstring(i)

also ricostring not object should not use set


Comments

Popular posts from this blog

wireshark - USB mapping with python -

c++ - nodejs socket.io closes connection before upgrading to websocket -

Deploying Qt Application on Android is really slow? -