vba - Array + Loop for Month and Year combination -
i trying create array months jan - dec , want have year "j14" january. want increase run move next month , after 12 runs year change "j15". run macro once month why want month , increase 1 each time run it. below have far, please excuse if wrong never used arrays before
sub test() dim myarray(1 12) integer myarray(1) = j myarray(2) = f myarray(3) = m myarray(4) = myarray(5) = m myarray(6) = j myarray(7) = j myarray(8) = myarray(9) = s myarray(10) = o myarray(11) = n myarray(12) = d = 1 ubound(myarray) cells(i, 1).value = myarray(i) next end sub
this how work, if write "14" in range a13. idea learn data types first comment has proposed. furthermore, there many better ways it. still:
option explicit sub test() dim long dim myarray(1 12) string myarray(1) = "j" myarray(2) = "f" myarray(3) = "m" myarray(4) = "a" myarray(5) = "m" myarray(6) = "j" myarray(7) = "j" myarray(8) = "a" myarray(9) = "s" myarray(10) = "o" myarray(11) = "n" myarray(12) = "d" = 1 ubound(myarray) cells(i, 1).value = myarray(i) & cells(13, 1) next cells(13, 1) = cells(13, 1) + 1 end sub
Comments
Post a Comment