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

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -