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

Popular posts from this blog

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -

javascript - Using jquery append to add option values into a select element not working -

javascript - Restarting Supervisor and effect on FlaskSocketIO -