## Global Versus Public in Visual Basic

Q115512

The information in this article applies to:

- Microsoft Visual Basic for Applications version 1.0
- Microsoft Excel for Windows, version 5.0
- Microsoft Project for Windows, version 4.0

## SUMMARY

In Microsoft Visual Basic version 3.0, you can use the Global statement in the Declarations section of a module to declare a global variable. Global variables are available to all procedures in all forms and modules.
In Microsoft Visual Basic Programming System, Applications Edition, you can use the Public statement to declare a public variable, which makes the variable available to all procedures in the workbook or project.
The Public statement in Visual Basic, Applications Edition, performs the same action as the Global statement in Visual Basic version 3.0. The name Public is more intuitive when thought of in context with its counterpart, Private. When you use the Private statement to declare a variable as private, the variable is available only to the module in which it is declared.
The Global statement is supported for compatibility in Visual Basic, Applications Edition; however, Public is preferred.

## REFERENCES

For more information about the Public Statement, choose the Search button in the Visual Basic Reference and type:

> Public

Additional query words:

Keywords :
Issue type :
Technology : kbExcelSearch kbZNotKeyword6 kbExcel500 kbProjectSearch kbVBASearch kbZNotKeyword3 kbProject400 kbVBA100

Last Reviewed: January 17, 2001 © 2001 Microsoft Corporation. All rights reserved. Terms of Use.