ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Object not defined (https://www.excelbanter.com/excel-programming/284872-object-not-defined.html)

marko

Object not defined
 
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.



Chip Pearson

Object not defined
 
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


"marko" <no@email wrote in message
...
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

Object not defined
 
Thanks Chip

"Chip Pearson" wrote in message
...
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


"marko" <no@email wrote in message
...
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.








All times are GMT +1. The time now is 05:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com