I have previously defined Report_wb
in an module Obtain_Data
, and now I am writing a new module Module1
. I want to use the object Report_wb
without defining it again. Is there any way to do that? Thanks!
Asked
Active
Viewed 300 times
-1

Sijie Huang
- 21
- 3
-
If you make `Report_wb` public, then you can reference it in other modules as `Obtain_Data.Report_wb`. – xidgel Apr 25 '17 at 16:08
1 Answers
0
rather than declaring Report_wb as a dim within a sub, write it as a public declaration at the top of the module
i.e.
'Module 1
Public stringTest as string
Sub SetString()
stringTest = "Hello World!"
End Sub
and then in another module:
'Module 2
Sub TestString()
call SetString
debug.print stringTest
End Sub

Zerk
- 1,595
- 9
- 16
-
-
2@PaulOgilvie `Call` isn't required, but it may be used as a style preference by the author. – David Zemens Apr 25 '17 at 16:08
-
@PaulOgilvie syntactic sugar that has no impact on the purpose or functionality of the example. – Zerk Apr 25 '17 at 16:21