excel - VBA For loop not printing value to cell -
option explicit public sub autoserial() dim long dim b long dim c long dim d long dim e long = selection.row b = selection.rows.count + selection.row - 1 c = selection.column d = 1 e = e = b cells(e, c).value = d d = d + 1 next e end sub
this code manual ranking function. when run code, serial numbers should appear on first column of selection. nothing gets printed on column. also, no error shows up.
selection a1 d5
please try this, tidied , removed not required variables should print serial numbers in first column of selection
option explicit public sub autoserial() dim irowstart long dim irowend long dim icol long, irow long dim iincrement long irowkstart = selection.row irowend = selection.rows.count + selection.row - 1 icol = selection.column iincrement = 1 irow =irowstart irowend cells(irow, icol).value = iincrement iincrement = iincrement + 1 next irow end sub
Comments
Post a Comment