2

For example;

I have two Modules, as Module1 and Module2

There are commands as follows in Module1

   For i = 2 to 1000

And i want to use same "i" variable in Module2.

How can i call the "i" variable from the Module1

Thanx

Community
  • 1
  • 1
  • [https://stackoverflow.com/questions/2722146/how-do-i-declare-a-global-variable-in-vba][1] – GSD Oct 09 '17 at 19:19
  • Once you have made it `Public` in Module1, you can reference it within Module2 as `Module1.i`. (But if you are using `i` as a loop counter, then making it a `Public` variable is a bad, bad, bad idea.) – YowE3K Oct 09 '17 at 21:15

1 Answers1

0

Hi very simple this way use declare in module1

Option Explicit
Public i As Integer

after that you can access other modules i variable value

Ike
  • 9,580
  • 4
  • 13
  • 29
RAJEEV
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 14 '22 at 19:10