Excel VBA crashes by changing the value on a cell -
i new here , seek larn vba excel doesn't work.
i want function 1 paramter insert each cell increased value.
option explicit function defineai(rngtoset range) string dim intcounter integer dim cell range on error goto fehler allow intcounter = 1 each cell in rngtoset.cel 'cell.value = intcounter 'test 1: crashes no error range(cell).value = intcounter 'test 2: crashes no error intcounter = intcounter + 1 'intcounter++ ?? not of import yet next defineai = "test" exit function fehler: debug.print err.description end function
it crashes on 2 different computers no error! doesn't crash, stop.
i have seek sub, same result.
you cannot alter value of cell udf function
, cannot phone call sub
within udf function
changes value of cell. if looking run macro perform wish here code runs.
sub mcr_call_defineai() phone call mcr_defineai(range("d2:d10")) end sub private sub mcr_defineai(rngtoset range, optional istart long = 1) dim long, r range on error goto fehler = istart each r in rngtoset r = = + 1 next debug.print "test funktionierte!" exit sub fehler: debug.print err.description end sub
i've included optional parameter can alter starting number of increment.
excel vba
No comments:
Post a Comment