excel vba - Getting sheet by index causes error in vba macro -
i'm trying create macro in excel, following code causes error. can't why
public sub createsimplemodel() dim reportsheet worksheet msgbox thisworkbook.sheets.count reportsheet = thisworkbook.sheets(1) <-- here error end sub
the message box appears shows there sheets in workbook. error object variable or block not set
appreciated.
you need use "set" if want reference workbook
public sub createsimplemodel() dim reportsheet worksheet msgbox thisworkbook.sheets.count set reportsheet = thisworkbook.sheets(1) end sub
Comments
Post a Comment