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

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -