Object not defined

  • Thread starter Thread starter marko
  • Start date Start date
M

marko

Hi all,

This works

Dim debriefBook As Workbook

Sub booktest()
Set debriefBook = ThisWorkbook
MsgBox debriefBook.Name
End Sub

but if I call a function from a different module,

Sub ShowName
Set debriefBook = ThisWorkbook
ShowMe
End Sub

and this is in a different module!
Function Showme()
MsgBox debriefBook.Name
End Function
It doesnt work, it says "object not defined"
I'm not sure whats going on.
 
Marko,

Change the declaration of the variable to Public. I.e.,

Public debriefBook As Workbook


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Thanks Chip

Chip Pearson said:
Marko,

Change the declaration of the variable to Public. I.e.,

Public debriefBook As Workbook


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top