Compiler Error in Excel Vba -
i'm getting compiler error while running below code:
sub addnameinlist() filmname = inputbox("type in new film name") worksheets("sheet2").activate range("b1").end(xldown).offset(1, 0).select activecell.value = filmname msgbox filmname & " added list" end sub
error message
compiler error: variable not defined
you need declare filmname:
sub addnameinlist() dim filmname string filmname = inputbox("type in new film name") worksheets("sheet2").range("b1").end(xldown).offset(1, 0).value = filmname msgbox filmname & " added list" end sub
if have option explicit set either @ top of module or in settings requires variables declared.
also avoid using .select
, .activate
. in general not needed , slow down code.
Comments
Post a Comment