• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 414
  • 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 LissOlder than dirtCommented:
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 LissOlder than dirtCommented:
He's asking about sharing between workbooks.
0
 
IrogSintaCommented:
Oops my bad, my mind was thinking worksheets:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

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