excel vba - Sudden Random Error -


i have following code,

sub addzeroes() 'declarations dim integer, j integer, endrow long 'converts column format text format application.screenupdating = false columns("a:a").select selection.numberformat = "@" 'finds bottom row endrow = activesheet.range("a1").end(xldown).row 'selects top cell in column activesheet.range("a1").select 'loop move cell cell = 1 endrow - 1             'moves cell down 1. assumes there's header row starts @ row 2             activecell.offset(1, 0).select             'the do-while loop keeps adding zeroes front of cell value until hits     length of 7 while len(activecell.value) < 7                             activecell.value = "0" & activecell.value             loop next application.screenupdating = true end sub 

and adds preceding zeroes numbers , converts them text make them 7 charecters long if less 7. , has been working day , has stopped. keep getting error run time error 6 overflow. @ loss because has worked without issues day until now. keeps highlighting portion:

for = 1 endrow - 1 

any thoughts?

change line:

dim integer, j integer, endrow long 

to instead:

dim long, j long, endrow long 

integer variables can go 32,767. if row numbers higher that, need use long.


Comments

Popular posts from this blog

ruby on rails - Is it the correct way to implement belongs_to relation with factory girl? -

geolocation - Windows Phone 8 - Keeping background location tracking active beyond four hours -

Uncaught TypeError: Cannot read property 'parentNode' of null javascript -