excel vba - VBA index in function -
i'm new vba (10 hours) coming bit of python background. there vba equivilant python when comes indexing part of returned function? mean: if have vba code looks this:
split(worksheets("range").range("k2").offset(i, 0), "-", "-1")
and want third part of split, how output?
i imagine simple question can't seem think through. in advance!
if function setting value of variant/array variable, e.g.,:
dim myarray variant myarray = split(worksheets("range").range("k2").offset(i, 0), "-", "-1")
then should able refer 3rd item in array like:
debug.print myarray(2) 'option base 0 -- default'
or, if have option base 1
then:
debug.print myarray(3)
those examples use constant expression (2 or 3) index array item. use match function return dynamic value, e.g., let's looking value of "steve" in array:
dim aitem long aitem = application.match("steve", myarray, false)
this returns long/integer reference like:
debug.print myarray(aitem)
cheers!
Comments
Post a Comment