Last active
June 21, 2016 16:21
-
-
Save erajanraja24/3ee5a447d866b096f8161fb4597e76d2 to your computer and use it in GitHub Desktop.
Excel VBA Scope of variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'In Module 1 | |
| Option Private Module | |
| Public var1 As Integer | |
| Sub Public_Scope_1() | |
| var1 = 20 | |
| Debug.Print "Value of var1 in Public_Scope_1: "; var1 | |
| var1 = var1 + 15 | |
| End Sub | |
| 'Go to Developer tab, insert a Module by Insert->Module and copy paste the above code in the Module1 | |
| 'In Module 2 | |
| Sub Public_Scope_2() | |
| Debug.Print "Value of var1 in Public_Scope_2: "; var1 | |
| End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment