Excel VBA object sub call with 2 object parameters gives compile error: expected = -
i calling object's subroutine in microsoft excel vba. sub has 2 parameters, both objects themselves. line of code typed giving error-> compile error: expected =
here section of code occurs in:
' copy info old sheet , paste new sheet dim employee cemployee = 2 eswbmaxrow set employee = new cemployee employee.setnames (eswb.worksheets("employee info").cells(i, wbcolumns.infonamecol).value) employee.loadfromanotherworkbook(eswb,wbcolumns) ' <- line giving compile error next
i don't understand why is. code similar code have works fine.
this code works (note: separate function):
with thisworkbook.worksheets(sheet) while (.cells(i, 1).value <> empty) ' create object , set name property set employee = new cemployee employee.setnames (.cells(i, 1).value) employee.loadfromscratch ' <- sub identical 1 causing problem. difference doesn't take object parameters = + 1 loop end
this how declaring subroutine calling gives compile error:
public sub loadfromanotherworkbook(byval wb workbook, byval wbcolumns ccolumns)
the objects pass sub of correct type.
this isn't function, don't understand why need use equal sign. know doing wrong?
when calling sub
, don't enclose parameters in brackets
use this
employee.loadfromanotherworkbook eswb, wbcolumns
Comments
Post a Comment