Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 395
  • Last Modified:

Excel 2010 VBA - Using Public Variables and Constants in other workbooks?

Can Public Variables be used in workbooks other than the one they are declared in?
Example:
Workbook 1 is currently open and has a public variable declared TOTALSALES
Workbook 2 is also open.  Can this workbook use the TOTALSALES variable declared in Workbook 1?

How about using constants?   If constants are declared as PUBLIC?
0
brothertruffle880
Asked:
brothertruffle880
  • 2
  • 2
1 Solution
 
Martin LissRetired ProgrammerCommented:
No they can't be but you may be able to create functions  in the other workbook to return values.
0
 
IrogSintaCommented:
I don't think you can declare a constant as Public in an object module (such as a workbook) so the answer there is obviously no.  

As for Public variables, you certainly can refer to one from another worksheet following a convention similar to this:
MsgBox Sheets("Sheet1").TOTALSALES

Open in new window

0
 
Martin LissRetired ProgrammerCommented:
He's asking about sharing between workbooks.
0
 
IrogSintaCommented:
Oops my bad, my mind was thinking worksheets:-)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now