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 -

Laravel mail error `Swift_TransportException in StreamBuffer.php line 269: Connection could not be established with host smtp.gmail.com [ #0]` -

c# SetCompatibleTextRenderingDefault must be called before the first -