excel - How can I create a vector in VBA? -
i have little issue need create vector in excel vba.
i have next scenario
str=sheets("indata").range("$c$12") vector= str for illustration if cell in c12 11 want next output:
vector= "1 2 3 4 5 6 7 8 9 10 11"
numbers
sub test() dim str string str = join(application.transpose(evaluate("row(a1:a" & range("c12").value2 & ")")), " ") debug.print str end sub letters
sub test2() dim str string, varr, lcnt long varr = application.transpose(evaluate("64 + row(a1:a" & range("c12").value2 & ")")) lcnt = lbound(varr, 1) ubound(varr, 1) str = str & " " & chr(clng(varr(lcnt))) next lcnt debug.print str end sub update
loop avoider letters :
sub test3() dim str string const alphabet = "a b c d e f g h j k l m n o p q r s t u v w x y z" str = iif(clng(range("c12").value2) <= 26, _ mid(alphabet, 1, 1 + (2 *clng(range("c12").value2 - 1))), "error") debug.print str end sub you did not specify happens if value exceeds lastly letter, throw error. want?
excel vba excel-vba ms-word
No comments:
Post a Comment